@yaks/effects 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.
- package/LICENSE +202 -0
- package/README.md +979 -2
- package/_dist/docs.d.ts +10 -0
- package/_dist/docs.d.ts.map +1 -0
- package/_dist/enqueue.d.ts +12 -0
- package/_dist/enqueue.d.ts.map +1 -0
- package/_dist/expire.d.ts +31 -0
- package/_dist/expire.d.ts.map +1 -0
- package/_dist/invocation.d.ts +36 -0
- package/_dist/invocation.d.ts.map +1 -0
- package/_dist/lease.d.ts +98 -0
- package/_dist/lease.d.ts.map +1 -0
- package/_dist/mod.d.ts +89 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/outage.d.ts +48 -0
- package/_dist/outage.d.ts.map +1 -0
- package/_dist/pool.d.ts +148 -0
- package/_dist/pool.d.ts.map +1 -0
- package/_dist/provisional.d.ts +8 -0
- package/_dist/provisional.d.ts.map +1 -0
- package/_dist/ready.d.ts +3 -0
- package/_dist/ready.d.ts.map +1 -0
- package/_dist/registration.d.ts +17 -0
- package/_dist/registration.d.ts.map +1 -0
- package/_dist/registry.d.ts +153 -0
- package/_dist/registry.d.ts.map +1 -0
- package/_dist/tools.d.ts +21 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/trace.d.ts +63 -0
- package/_dist/trace.d.ts.map +1 -0
- package/_dist/views.d.ts +15 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +11 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/worker.d.ts +19 -0
- package/_dist/worker.d.ts.map +1 -0
- package/_dist/write.d.ts +25 -0
- package/_dist/write.d.ts.map +1 -0
- package/cleanup.js +75 -0
- package/cleanup.js.map +1 -0
- package/cleanup.ts +83 -0
- package/deno.json +1 -0
- package/docs.js +13 -0
- package/docs.js.map +1 -0
- package/docs.ts +13 -0
- package/enqueue.js +71 -0
- package/enqueue.js.map +1 -0
- package/enqueue.ts +86 -0
- package/expire.js +225 -0
- package/expire.js.map +1 -0
- package/expire.ts +244 -0
- package/invocation.js +245 -0
- package/invocation.js.map +1 -0
- package/invocation.ts +250 -0
- package/lease.js +343 -0
- package/lease.js.map +1 -0
- package/lease.ts +444 -0
- package/mod.js +89 -0
- package/mod.js.map +1 -0
- package/mod.ts +92 -0
- package/outage.js +77 -0
- package/outage.js.map +1 -0
- package/outage.ts +84 -0
- package/package.json +52 -4
- package/page.js +315 -0
- package/page.js.map +1 -0
- package/page.ts +524 -0
- package/pool.js +1474 -0
- package/pool.js.map +1 -0
- package/pool.ts +1635 -0
- package/provisional.js +20 -0
- package/provisional.js.map +1 -0
- package/provisional.ts +26 -0
- package/ready.js +48 -0
- package/ready.js.map +1 -0
- package/ready.ts +93 -0
- package/registration.js +21 -0
- package/registration.js.map +1 -0
- package/registration.ts +43 -0
- package/registry.js +872 -0
- package/registry.js.map +1 -0
- package/registry.ts +1196 -0
- package/tools.js +182 -0
- package/tools.js.map +1 -0
- package/tools.ts +229 -0
- package/trace.js +167 -0
- package/trace.js.map +1 -0
- package/trace.ts +217 -0
- package/views.js +18 -0
- package/views.js.map +1 -0
- package/views.ts +18 -0
- package/vocab.js +18 -0
- package/vocab.js.map +1 -0
- package/vocab.json +364 -0
- package/vocab.ts +20 -0
- package/worker.js +114 -0
- package/worker.js.map +1 -0
- package/worker.ts +146 -0
- package/write.js +38 -0
- package/write.js.map +1 -0
- package/write.ts +60 -0
package/trace.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// What happened, worked out from what was committed. The bundles a client
|
|
2
|
+
// sends record only what to write: the same bundle patches a component that
|
|
3
|
+
// already existed and creates one that did not, and a cascade's casualty comes
|
|
4
|
+
// back as a bare tombstone with none of the components it used to carry. A
|
|
5
|
+
// handler needs the difference — "a post was published" is not "a post exists"
|
|
6
|
+
// — so this file derives it.
|
|
7
|
+
//
|
|
8
|
+
// It takes two readings. BEFORE the patches go in, `before()` reads what each
|
|
9
|
+
// entity in the batch carries, plus the same for everything the batch is about
|
|
10
|
+
// to delete (@yaks/graph's own `doomed()` walk, so the death rule is reused,
|
|
11
|
+
// never re-implemented). After the commit, `events()` replays the applied
|
|
12
|
+
// batch against that reading: a component absent before is a creation, one
|
|
13
|
+
// present before is a change carrying only the properties that moved, and a
|
|
14
|
+
// component or an entity that went is a removal, carrying that component as it
|
|
15
|
+
// was. That is the one thing a handler cannot read afterwards: a deleted edge
|
|
16
|
+
// no longer says which ends it had. A removal carries its own component and
|
|
17
|
+
// nothing else the entity lost, so a run kept for it never copies the rest: a
|
|
18
|
+
// handler that needs a deleted link's ends watches `edge` going.
|
|
19
|
+
//
|
|
20
|
+
// The reading rides forward on the batch itself, under `$before`. A `$`-key is
|
|
21
|
+
// not a component — `comps()` skips it, so no storage adapter ever sees it —
|
|
22
|
+
// which is how one phase of `apply()` passes what it learned to a later one
|
|
23
|
+
// without a global anywhere. The effect phase strips it back off.
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
Actor,
|
|
27
|
+
Ask,
|
|
28
|
+
Binding,
|
|
29
|
+
Bundle,
|
|
30
|
+
Comp,
|
|
31
|
+
Eid,
|
|
32
|
+
Entity,
|
|
33
|
+
Tx,
|
|
34
|
+
} from 'jsr:@yaks/graph@0.2.36'
|
|
35
|
+
import { after } from '@yaks/fp'
|
|
36
|
+
import { comps, dead } from '@yaks/graph/bundle'
|
|
37
|
+
import { doomed } from '@yaks/graph/read'
|
|
38
|
+
import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
39
|
+
import type { Invocation } from './invocation.ts'
|
|
40
|
+
|
|
41
|
+
/** What triggered a handler: one of the three things that can happen to a
|
|
42
|
+
* component, or a pattern that is now true over what the batch committed. */
|
|
43
|
+
export type Kind = 'created' | 'changed' | 'removed' | 'matched' | 'started'
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* One committed component change, as an effect sees it.
|
|
47
|
+
*
|
|
48
|
+
* `comp` is the patch as applied, which is what makes a change readable: on a
|
|
49
|
+
* `created` event it is the whole birth row, on a `changed` event only the
|
|
50
|
+
* properties that moved, and on a `removed` event there is nothing left to
|
|
51
|
+
* carry. What went is `before` instead: the component, as it stood before the
|
|
52
|
+
* commit.
|
|
53
|
+
*/
|
|
54
|
+
export type Event = {
|
|
55
|
+
/** When the committed change owed this durable run, preserved across retries. */
|
|
56
|
+
at?: string
|
|
57
|
+
/** This execution's durable pool row. */
|
|
58
|
+
run?: Eid
|
|
59
|
+
/** Inputs captured when the declared match committed. */
|
|
60
|
+
invocation?: Invocation
|
|
61
|
+
/** what happened */
|
|
62
|
+
kind: Kind
|
|
63
|
+
/** the entity it happened to, with the `num` storage minted */
|
|
64
|
+
entity: Entity
|
|
65
|
+
/** the component's name */
|
|
66
|
+
name: string
|
|
67
|
+
/** Components this commit moved on the same entity, including removals. */
|
|
68
|
+
touched?: string[]
|
|
69
|
+
/** the properties the change carried (absent on `removed`) */
|
|
70
|
+
comp?: Comp
|
|
71
|
+
/** on `removed`, the entity holding the component that went, as the commit
|
|
72
|
+
* found it, and no other. Absent where nothing was read before the commit
|
|
73
|
+
* (a component born and removed in one batch). */
|
|
74
|
+
before?: Bundle
|
|
75
|
+
/** what each variable bound, for a `matched` event whose pattern named some */
|
|
76
|
+
vars?: Record<string, unknown>
|
|
77
|
+
/** the whole multi-entity match, including its collected members */
|
|
78
|
+
binding?: Binding
|
|
79
|
+
/** Who wrote the commit, as its batch signed the entity: absent for
|
|
80
|
+
* automation. A run that writes on the commit's behalf (a call it asks
|
|
81
|
+
* for) signs with it, `signed(bundles, event.actor)`, as a rule inside
|
|
82
|
+
* the write is; what it writes unsigned is automation. */
|
|
83
|
+
actor?: Actor
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** What each entity carried before the batch: its row, by eid. */
|
|
87
|
+
export type Before = Record<Eid, Bundle>
|
|
88
|
+
|
|
89
|
+
/** The key the reading rides forward on. Not a component: `$`-prefixed keys
|
|
90
|
+
* are `apply()`'s pipeline, never properties, so storage never sees it. */
|
|
91
|
+
export let BEFORE = '$before'
|
|
92
|
+
|
|
93
|
+
// The entities this batch deletes, written either way.
|
|
94
|
+
let killing = (bundles: Bundle[]): Eid[] => [
|
|
95
|
+
...new Set(bundles.filter(dead).map((b) => b.entity.eid)),
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Read what the batch's entities — and everything that will die with them —
|
|
100
|
+
* carry right now, and ride it forward on the batch. Registered on the
|
|
101
|
+
* `precondition` phase, so it reads inside the transaction and before a single
|
|
102
|
+
* patch has gone in.
|
|
103
|
+
*/
|
|
104
|
+
export let before = (
|
|
105
|
+
vocab: Vocab,
|
|
106
|
+
) =>
|
|
107
|
+
(bundles: Bundle[], tx: Tx): Bundle[] | Promise<Bundle[]> => {
|
|
108
|
+
let killed = killing(bundles)
|
|
109
|
+
return after(
|
|
110
|
+
killed.length ? doomed(tx, vocab, killed) : [],
|
|
111
|
+
(gone) =>
|
|
112
|
+
after(
|
|
113
|
+
tx.get([...new Set([...bundles.map((b) => b.entity.eid), ...gone])]),
|
|
114
|
+
(found) => {
|
|
115
|
+
let map: Before = {}
|
|
116
|
+
for (let b of found) map[b.entity.eid] = b
|
|
117
|
+
return bundles.map((b) => ({ ...b, [BEFORE]: map }))
|
|
118
|
+
},
|
|
119
|
+
),
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* What {@link before} is about to read, declared before it reads it: every
|
|
125
|
+
* entity the batch is about, and — for a delete — everything pointing at what
|
|
126
|
+
* is being deleted, which is what the `doomed()` walk asks. Declared as the
|
|
127
|
+
* plugin's `wants` so @yaks/graph gathers both in one pass.
|
|
128
|
+
*/
|
|
129
|
+
export let wanting = (vocab: Vocab) => (bundles: Bundle[]): Ask[] => {
|
|
130
|
+
let killed = killing(bundles)
|
|
131
|
+
return [
|
|
132
|
+
{ eids: bundles.map((b) => b.entity.eid) },
|
|
133
|
+
...(killed.length
|
|
134
|
+
? [{
|
|
135
|
+
about: killed,
|
|
136
|
+
comps: [...new Set(vocab.deaths('cascade').map(([c]) => c))],
|
|
137
|
+
}]
|
|
138
|
+
: []),
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Take the reading back off, so the batch a caller gets back is the batch as
|
|
144
|
+
* applied and nothing else. Done in place, deliberately: `apply()` returns the
|
|
145
|
+
* bundles it committed rather than what the effect phase returns, so a copy
|
|
146
|
+
* made here would be a copy nobody reads. The bundles it edits are the ones
|
|
147
|
+
* `before()` copied, never the caller's own.
|
|
148
|
+
*/
|
|
149
|
+
export let strip = (bundles: Bundle[]): Bundle[] => {
|
|
150
|
+
for (let b of bundles) if (BEFORE in b) delete b[BEFORE]
|
|
151
|
+
return bundles
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The committed batch, read as what happened. Replays the bundles in order
|
|
156
|
+
* against the reading `before()` took: a component the entity did not carry is
|
|
157
|
+
* `created` (once — a second patch for it in the same batch is a `changed`), a
|
|
158
|
+
* component it did carry is `changed`, a null component or a deleted entity is
|
|
159
|
+
* `removed`, one event per component the casualty carried, each carrying
|
|
160
|
+
* `before`: that component, as the reading found it.
|
|
161
|
+
*/
|
|
162
|
+
export let events = (bundles: Bundle[]): Event[] => {
|
|
163
|
+
let map = (bundles.find((b) => b[BEFORE])?.[BEFORE] ?? {}) as Before
|
|
164
|
+
// A new entity's `num` rides back on its own bundle, so an event about the
|
|
165
|
+
// entity that was just created can carry the number storage gave it.
|
|
166
|
+
let nums = new Map<Eid, number>()
|
|
167
|
+
for (let b of bundles) {
|
|
168
|
+
if (b.entity.num != null) nums.set(b.entity.eid, b.entity.num)
|
|
169
|
+
}
|
|
170
|
+
let named = (e: Entity): Entity =>
|
|
171
|
+
e.num != null || !nums.has(e.eid) ? e : { ...e, num: nums.get(e.eid) }
|
|
172
|
+
// What each entity carries as the replay walks the batch, so the batch's own
|
|
173
|
+
// earlier bundles count: created then patched is one creation, not two.
|
|
174
|
+
let held = new Map<Eid, Set<string>>()
|
|
175
|
+
let has = (eid: Eid): Set<string> => {
|
|
176
|
+
let s = held.get(eid)
|
|
177
|
+
if (!s) {
|
|
178
|
+
held.set(
|
|
179
|
+
eid,
|
|
180
|
+
s = new Set(map[eid] ? comps(map[eid]).map(([n]) => n) : []),
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
return s
|
|
184
|
+
}
|
|
185
|
+
let removed = (entity: Entity, name: string): Event => {
|
|
186
|
+
let was = map[entity.eid]?.[name]
|
|
187
|
+
return was == null
|
|
188
|
+
? { kind: 'removed', entity, name }
|
|
189
|
+
: { kind: 'removed', entity, name, before: { entity, [name]: was } }
|
|
190
|
+
}
|
|
191
|
+
let out: Event[] = []
|
|
192
|
+
for (let b of bundles) {
|
|
193
|
+
let entity = named(b.entity)
|
|
194
|
+
let carried = has(entity.eid)
|
|
195
|
+
if (dead(b)) {
|
|
196
|
+
for (let name of carried) out.push(removed(entity, name))
|
|
197
|
+
carried.clear()
|
|
198
|
+
continue
|
|
199
|
+
}
|
|
200
|
+
for (let [name, comp] of comps(b)) {
|
|
201
|
+
if (comp == null) {
|
|
202
|
+
if (carried.delete(name)) out.push(removed(entity, name))
|
|
203
|
+
continue
|
|
204
|
+
}
|
|
205
|
+
let born = !carried.has(name)
|
|
206
|
+
carried.add(name)
|
|
207
|
+
out.push({ kind: born ? 'created' : 'changed', entity, name, comp })
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
let touched = new Map<Eid, Set<string>>()
|
|
211
|
+
for (let e of out) {
|
|
212
|
+
let names = touched.get(e.entity.eid) ?? new Set<string>()
|
|
213
|
+
names.add(e.name)
|
|
214
|
+
touched.set(e.entity.eid, names)
|
|
215
|
+
}
|
|
216
|
+
return out.map((e) => ({ ...e, touched: [...touched.get(e.entity.eid)!] }))
|
|
217
|
+
}
|
package/views.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// The `@yaks/effects/views` facet: the page the sidebar offers as Effects
|
|
2
|
+
// (./page.ts), loaded only by an interface that draws it.
|
|
3
|
+
// @ts-types="@yaks/ui/lucide"
|
|
4
|
+
import Gauge from "lucide/dist/esm/icons/gauge.mjs";
|
|
5
|
+
/** The page, as the inspector draws it. */ export let inspectViews = ()=>import("./page.js").then((m)=>m.inspectViews);
|
|
6
|
+
/** The page the sidebar offers: the workers, what each is running and how
|
|
7
|
+
* busy it is, and the runs owed behind them. */ export let destinations = [
|
|
8
|
+
{
|
|
9
|
+
key: 'effects',
|
|
10
|
+
name: 'Effects',
|
|
11
|
+
icon: 'gauge',
|
|
12
|
+
view: 'Effects.Page'
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
/** The glyph it wears there. */ export let icons = {
|
|
16
|
+
gauge: Gauge
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=views.js.map
|
package/views.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sources":["./views.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0DAA0D;AAE1D,8BAA8B;AAC9B,OAAO,6CAAuD;AAE9D,yCAAyC,GACzC,OAAO,IAAI,eAAe,IACxB,MAAM,CAAC,aAAa,IAAI,CAAC,CAAC,IAAM,EAAE,YAAY,EAAC;AAEjD;8CAC8C,GAC9C,OAAO,IAAI,eAAe;EACxB;IAAE,KAAK;IAAW,MAAM;IAAW,MAAM;IAAS,MAAM;EAAe;CACxE,CAAA;AAED,8BAA8B,GAC9B,OAAO,IAAI,QAAQ;EAAE,OAAO;AAAM,EAAC"}
|
package/views.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// The `@yaks/effects/views` facet: the page the sidebar offers as Effects
|
|
2
|
+
// (./page.ts), loaded only by an interface that draws it.
|
|
3
|
+
import type { View } from 'jsr:@yaks/inspect@0.2.36'
|
|
4
|
+
// @ts-types="@yaks/ui/lucide"
|
|
5
|
+
import Gauge from 'lucide/dist/esm/icons/gauge.mjs'
|
|
6
|
+
|
|
7
|
+
/** The page, as the inspector draws it. */
|
|
8
|
+
export let inspectViews = (): Promise<View[]> =>
|
|
9
|
+
import('./page.js').then((m) => m.inspectViews)
|
|
10
|
+
|
|
11
|
+
/** The page the sidebar offers: the workers, what each is running and how
|
|
12
|
+
* busy it is, and the runs owed behind them. */
|
|
13
|
+
export let destinations = [
|
|
14
|
+
{ key: 'effects', name: 'Effects', icon: 'gauge', view: 'Effects.Page' },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
/** The glyph it wears there. */
|
|
18
|
+
export let icons = { gauge: Gauge }
|
package/vocab.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// The component declarations, and only those: the module exported as
|
|
2
|
+
// `@yaks/effects/vocab`. It imports no storage, no SQL and no runtime, so a
|
|
3
|
+
// browser tab that loads this vocabulary loads nothing else.
|
|
4
|
+
import { effectDoc } from "./docs.js";
|
|
5
|
+
import { provisionalDoc } from "./provisional.js";
|
|
6
|
+
import manifest from './package.json' with {
|
|
7
|
+
type: 'json'
|
|
8
|
+
};
|
|
9
|
+
export { effectDoc, provisionalDoc };
|
|
10
|
+
/** What this package is: its manifest's description, the one place it is
|
|
11
|
+
* written, which a host stamps on each document here. */ export let description = manifest.description;
|
|
12
|
+
/** Every document this plugin declares — the pool's `effect` rows, which an
|
|
13
|
+
* application loads when effects are to be written down and worked by any
|
|
14
|
+
* process, the `lease` a duty is held under, and the `provisional` mark. A
|
|
15
|
+
* vocabulary that wants only the mark loads `provisionalDoc` instead. */ export let docs = [
|
|
16
|
+
effectDoc
|
|
17
|
+
];
|
|
18
|
+
//# sourceMappingURL=vocab.js.map
|
package/vocab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,4EAA4E;AAC5E,6DAA6D;AAG7D,SAAS,SAAS,oBAAmB;AACrC,SAAS,cAAc,2BAA0B;AACjD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,SAAS,SAAS,EAAE,cAAc,GAAE;AAEpC;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD;;;uEAGuE,GACvE,OAAO,IAAI,OAAmB;EAAC;CAAU,CAAA"}
|
package/vocab.json
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "urn:uuid:f144dc01-40ae-4520-a926-0211ac38d229",
|
|
3
|
+
"$vocabulary": {
|
|
4
|
+
"https://yak.sh/vocab/core": true,
|
|
5
|
+
"https://yak.sh/vocab/fence": true
|
|
6
|
+
},
|
|
7
|
+
"title": "effect",
|
|
8
|
+
"$defs": {
|
|
9
|
+
"effect": {
|
|
10
|
+
"$id": "urn:uuid:08192132-d4a8-4912-aa88-2222c18dbb4b",
|
|
11
|
+
"component": true,
|
|
12
|
+
"fence": "own",
|
|
13
|
+
"wire": false,
|
|
14
|
+
"index": [
|
|
15
|
+
["handler", "state", "at"],
|
|
16
|
+
[
|
|
17
|
+
"handler",
|
|
18
|
+
"state",
|
|
19
|
+
"lease_owner",
|
|
20
|
+
"next"
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"handler",
|
|
24
|
+
"state",
|
|
25
|
+
"next",
|
|
26
|
+
"lease_expiry"
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
"handler",
|
|
30
|
+
"state",
|
|
31
|
+
"lease_expiry",
|
|
32
|
+
"next"
|
|
33
|
+
]
|
|
34
|
+
],
|
|
35
|
+
"type": "object",
|
|
36
|
+
"journal": false,
|
|
37
|
+
"description": "read-only record of a background run owed by a commit. To list recent runs, query .effect .order=-effect.at .limit=20",
|
|
38
|
+
"properties": {
|
|
39
|
+
"handler": {
|
|
40
|
+
"$id": "urn:uuid:cf0ea4db-e5e8-418f-9122-a83f3044a2f4",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"stamped": true,
|
|
43
|
+
"description": "the declared effect it runs, by name"
|
|
44
|
+
},
|
|
45
|
+
"invocation": {
|
|
46
|
+
"$id": "urn:uuid:2335b9ab-78cb-4de4-bb9d-00fd94c5639c",
|
|
47
|
+
"type": "object",
|
|
48
|
+
"stamped": true,
|
|
49
|
+
"description": "call or match arguments captured in the commit that owed the operation"
|
|
50
|
+
},
|
|
51
|
+
"target": {
|
|
52
|
+
"$id": "urn:uuid:742ba7de-da47-4b52-9799-e9e82718e46c",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"ref": "entity",
|
|
55
|
+
"death": "keep",
|
|
56
|
+
"stamped": true,
|
|
57
|
+
"description": "the entity the committed change was about"
|
|
58
|
+
},
|
|
59
|
+
"comp": {
|
|
60
|
+
"$id": "urn:uuid:02fdd8ae-883b-4f6d-90b9-facf1c22867e",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"stamped": true,
|
|
63
|
+
"description": "the component that changed"
|
|
64
|
+
},
|
|
65
|
+
"touched": {
|
|
66
|
+
"$id": "urn:uuid:50698ec9-f55f-4b7c-b220-c0198edfe426",
|
|
67
|
+
"type": "array",
|
|
68
|
+
"items": {
|
|
69
|
+
"type": "string"
|
|
70
|
+
},
|
|
71
|
+
"stamped": true,
|
|
72
|
+
"description": "components moved on the target by the same commit"
|
|
73
|
+
},
|
|
74
|
+
"before": {
|
|
75
|
+
"$id": "urn:uuid:7400ae2d-c972-4093-9b97-1994ad93b051",
|
|
76
|
+
"type": "object",
|
|
77
|
+
"additionalProperties": true,
|
|
78
|
+
"stamped": true,
|
|
79
|
+
"description": "on a `removed` run, the component it is about as it was before the commit, by name, since the run cannot read it afterwards"
|
|
80
|
+
},
|
|
81
|
+
"kind": {
|
|
82
|
+
"$id": "urn:uuid:00e74f77-a06d-43b1-9c26-5a7e609a3633",
|
|
83
|
+
"type": "string",
|
|
84
|
+
"enum": [
|
|
85
|
+
"created",
|
|
86
|
+
"changed",
|
|
87
|
+
"removed",
|
|
88
|
+
"matched",
|
|
89
|
+
"started"
|
|
90
|
+
],
|
|
91
|
+
"stamped": true,
|
|
92
|
+
"description": "what happened to it, `matched` where a query matched it, or `started` where the target is a process that started working the effects"
|
|
93
|
+
},
|
|
94
|
+
"state": {
|
|
95
|
+
"$id": "urn:uuid:230e36c5-8ae3-4268-8617-d80af06826ab",
|
|
96
|
+
"type": "string",
|
|
97
|
+
"enum": [
|
|
98
|
+
"pending",
|
|
99
|
+
"done",
|
|
100
|
+
"failed"
|
|
101
|
+
],
|
|
102
|
+
"stamped": true,
|
|
103
|
+
"description": "set by the worker that runs the effect. It stays pending until the worker settles it. To retry a failed run after fixing its cause, use the store's effect retry command",
|
|
104
|
+
"index": true
|
|
105
|
+
},
|
|
106
|
+
"attempts": {
|
|
107
|
+
"$id": "urn:uuid:80bbff40-1c55-4b2c-9578-58327f46bb22",
|
|
108
|
+
"type": "number",
|
|
109
|
+
"stamped": true,
|
|
110
|
+
"description": "how many attempts the handler has spent; waiting through defer does not spend an attempt"
|
|
111
|
+
},
|
|
112
|
+
"at": {
|
|
113
|
+
"$id": "urn:uuid:2f1032ac-2beb-4e18-a00c-594a28ce9d5e",
|
|
114
|
+
"type": "string",
|
|
115
|
+
"format": "date-time",
|
|
116
|
+
"stamped": true,
|
|
117
|
+
"description": "when the run was recorded"
|
|
118
|
+
},
|
|
119
|
+
"generation": {
|
|
120
|
+
"$id": "urn:uuid:68d3bc10-4dd1-4511-b83f-76a6c08db0e6",
|
|
121
|
+
"type": "number",
|
|
122
|
+
"stamped": true,
|
|
123
|
+
"description": "how deep in effect-written batches the commit that owed it was: 0 for a client's write, 1 for an effect's own, so what this run writes is one more"
|
|
124
|
+
},
|
|
125
|
+
"actor": {
|
|
126
|
+
"$id": "urn:uuid:4532c304-d559-40c2-adec-b38c4ec8c5ca",
|
|
127
|
+
"type": "object",
|
|
128
|
+
"stamped": true,
|
|
129
|
+
"description": "the by/via pair that wrote the commit that owed it, so a write the run makes on that commit's behalf is signed as it was; absent for automation"
|
|
130
|
+
},
|
|
131
|
+
"error": {
|
|
132
|
+
"$id": "urn:uuid:2f6ac8b5-0cd3-4fad-b931-65c5946d0fb4",
|
|
133
|
+
"type": "string",
|
|
134
|
+
"stamped": true,
|
|
135
|
+
"description": "what the last attempt threw — kept beside a run left failed, so the record shows why"
|
|
136
|
+
},
|
|
137
|
+
"next": {
|
|
138
|
+
"$id": "urn:uuid:20eacbaf-d8d2-4c12-85c5-f2290f1356f5",
|
|
139
|
+
"type": "string",
|
|
140
|
+
"format": "date-time",
|
|
141
|
+
"stamped": true,
|
|
142
|
+
"description": "when the run next becomes eligible after failure backoff or deferred readiness; absent means a run nobody has started or one in progress"
|
|
143
|
+
},
|
|
144
|
+
"waiting": {
|
|
145
|
+
"$id": "urn:uuid:c8591190-9f80-4367-8b53-20d3573f892b",
|
|
146
|
+
"type": "string",
|
|
147
|
+
"stamped": true,
|
|
148
|
+
"description": "the readiness condition the handler last found unmet when it deferred this run"
|
|
149
|
+
},
|
|
150
|
+
"version": {
|
|
151
|
+
"$id": "urn:uuid:e04367e6-6278-4cf6-a657-3b40afb1bb17",
|
|
152
|
+
"type": "string",
|
|
153
|
+
"stamped": true,
|
|
154
|
+
"description": "the code version its latest attempt started on, where the host names one: resumed under another, a deploy cut the attempt off and it runs again as the same attempt; under the same one, its process crashed and that spends an attempt"
|
|
155
|
+
},
|
|
156
|
+
"lease_owner": {
|
|
157
|
+
"$id": "urn:uuid:a60afb70-7a6d-4177-b555-a17a50262929",
|
|
158
|
+
"type": "string",
|
|
159
|
+
"stamped": true,
|
|
160
|
+
"description": "the process that claimed this run",
|
|
161
|
+
"index": true
|
|
162
|
+
},
|
|
163
|
+
"lease_token": {
|
|
164
|
+
"$id": "urn:uuid:11ba3bb1-0efa-4ca2-af7f-b35564bffbac",
|
|
165
|
+
"type": "string",
|
|
166
|
+
"stamped": true,
|
|
167
|
+
"description": "that claim's token, fresh on every claim"
|
|
168
|
+
},
|
|
169
|
+
"lease_expiry": {
|
|
170
|
+
"$id": "urn:uuid:eb82dc8c-ea4c-4e5d-8952-d113de3f3163",
|
|
171
|
+
"type": "string",
|
|
172
|
+
"format": "date-time",
|
|
173
|
+
"stamped": true,
|
|
174
|
+
"description": "when the claim expires and another process may take it"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"lease": {
|
|
179
|
+
"$id": "urn:uuid:5ad53d0f-a5e0-41d8-a31e-31ade78c7be3",
|
|
180
|
+
"component": true,
|
|
181
|
+
"type": "object",
|
|
182
|
+
"journal": false,
|
|
183
|
+
"description": "a duty held by one process at a time — its eid is derived from `name`, so two processes reaching for the same duty address one row and the winner is settled by the graph's own precondition; plumbing between the processes on one store, so it is not history",
|
|
184
|
+
"properties": {
|
|
185
|
+
"name": {
|
|
186
|
+
"$id": "urn:uuid:cf56a038-8db0-42fa-9a63-986ad6452e1a",
|
|
187
|
+
"type": "string",
|
|
188
|
+
"description": "the duty being held — a sweep, a clock, a start-up pass; the eid is derived from it, so the same duty is the same row in every graph"
|
|
189
|
+
},
|
|
190
|
+
"holder": {
|
|
191
|
+
"$id": "urn:uuid:9739435a-de84-428f-846d-e3d782371272",
|
|
192
|
+
"type": "string",
|
|
193
|
+
"ref": "entity",
|
|
194
|
+
"death": "detach",
|
|
195
|
+
"description": "the process running it — absent means nobody is, and the next process to ask gets it"
|
|
196
|
+
},
|
|
197
|
+
"until": {
|
|
198
|
+
"$id": "urn:uuid:a2f22992-5e47-4cc8-bf42-d7d68c63026b",
|
|
199
|
+
"type": "string",
|
|
200
|
+
"format": "date-time",
|
|
201
|
+
"description": "when the hold expires; a holder still working pushes this out on a timer, and one that was killed leaves a row that expires without anything having to clean up after it"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"worker": {
|
|
206
|
+
"$id": "urn:uuid:02d13d39-0c35-4abe-913a-09728be2672c",
|
|
207
|
+
"component": true,
|
|
208
|
+
"type": "object",
|
|
209
|
+
"journal": false,
|
|
210
|
+
"description": "what a process working the effect pool says about itself, on its own process entity, every fifteen seconds while it works: how many runs it has going and the oldest of them, how many it has finished, and how busy it is. A row whose `at` stops moving is a worker that stopped saying, because it ended or its thread is stuck; one leaving the pool takes its row with it, and the next worker to start clears the row of one that was killed",
|
|
211
|
+
"properties": {
|
|
212
|
+
"at": {
|
|
213
|
+
"$id": "urn:uuid:4a1e9eb7-f2e4-4b38-b3c6-7a8e699fa23a",
|
|
214
|
+
"type": "string",
|
|
215
|
+
"format": "date-time",
|
|
216
|
+
"stamped": true,
|
|
217
|
+
"description": "when it last said this"
|
|
218
|
+
},
|
|
219
|
+
"running": {
|
|
220
|
+
"$id": "urn:uuid:04c2dfe8-5cda-468f-840b-2f03e3877183",
|
|
221
|
+
"type": "integer",
|
|
222
|
+
"stamped": true,
|
|
223
|
+
"description": "how many runs it has going"
|
|
224
|
+
},
|
|
225
|
+
"runs": {
|
|
226
|
+
"$id": "urn:uuid:c73a516a-7225-4a52-89ac-a8388530bbb3",
|
|
227
|
+
"type": "array",
|
|
228
|
+
"items": {
|
|
229
|
+
"type": "object",
|
|
230
|
+
"properties": {
|
|
231
|
+
"run": {
|
|
232
|
+
"type": "string",
|
|
233
|
+
"description": "the run's `effect` row"
|
|
234
|
+
},
|
|
235
|
+
"handler": {
|
|
236
|
+
"type": "string",
|
|
237
|
+
"description": "the declared effect it runs"
|
|
238
|
+
},
|
|
239
|
+
"target": {
|
|
240
|
+
"type": "string",
|
|
241
|
+
"description": "the entity it runs for"
|
|
242
|
+
},
|
|
243
|
+
"since": {
|
|
244
|
+
"type": "string",
|
|
245
|
+
"format": "date-time",
|
|
246
|
+
"description": "when it started"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"stamped": true,
|
|
251
|
+
"description": "the runs it has going, oldest first, at most twenty"
|
|
252
|
+
},
|
|
253
|
+
"ran": {
|
|
254
|
+
"$id": "urn:uuid:1196b47d-89af-4de1-8db8-51c79c07399a",
|
|
255
|
+
"type": "integer",
|
|
256
|
+
"stamped": true,
|
|
257
|
+
"description": "how many runs it has finished since it started, however each ended"
|
|
258
|
+
},
|
|
259
|
+
"errors": {
|
|
260
|
+
"$id": "urn:uuid:ff862089-7b99-4550-9f25-cda92624fddf",
|
|
261
|
+
"type": "integer",
|
|
262
|
+
"stamped": true,
|
|
263
|
+
"description": "how many of those threw"
|
|
264
|
+
},
|
|
265
|
+
"history": {
|
|
266
|
+
"$id": "urn:uuid:322975e9-3d07-438b-b1cd-ebb352337cf9",
|
|
267
|
+
"type": "array",
|
|
268
|
+
"items": {
|
|
269
|
+
"type": "integer"
|
|
270
|
+
},
|
|
271
|
+
"stamped": true,
|
|
272
|
+
"description": "how many runs it finished in each of the last sixty whole seconds, oldest first"
|
|
273
|
+
},
|
|
274
|
+
"cpu": {
|
|
275
|
+
"$id": "urn:uuid:f261b0a0-df10-4e09-aff9-2733c083747f",
|
|
276
|
+
"type": "number",
|
|
277
|
+
"stamped": true,
|
|
278
|
+
"description": "the share of one core its process used since it last said, 1 being a whole core; absent where its host cannot tell"
|
|
279
|
+
},
|
|
280
|
+
"lag": {
|
|
281
|
+
"$id": "urn:uuid:5df7748c-adb5-4f3f-bbe1-b7b6212f84bc",
|
|
282
|
+
"type": "integer",
|
|
283
|
+
"stamped": true,
|
|
284
|
+
"description": "the longest its thread ran a timer late since it last said, in milliseconds: how full its event loop is"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
"provisional": {
|
|
289
|
+
"$id": "urn:uuid:9812181d-27c8-40ad-a9fd-cd4a5f68b8a4",
|
|
290
|
+
"component": true,
|
|
291
|
+
"fence": "own",
|
|
292
|
+
"journal": false,
|
|
293
|
+
"type": "object",
|
|
294
|
+
"description": "an entity whose asynchronous step has not finished yet: it sits where it always does, and the effect that finishes the step removes this mark. A reader who sees it knows the entity is not settled; the writer who started the step waits for it and never sees the mark",
|
|
295
|
+
"properties": {
|
|
296
|
+
"note": {
|
|
297
|
+
"$id": "urn:uuid:046d3d6f-a1da-44d5-b565-4ff2161554e2",
|
|
298
|
+
"type": "string",
|
|
299
|
+
"description": "a line for the person reading it: why the entity is provisional, such as \"saving the key\""
|
|
300
|
+
},
|
|
301
|
+
"resume_on": {
|
|
302
|
+
"$id": "urn:uuid:74b8945e-dfcc-443f-bdb6-53e9dac1d335",
|
|
303
|
+
"type": "string",
|
|
304
|
+
"index": true,
|
|
305
|
+
"description": "The external event that can resume this wait."
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
"effect_check": {
|
|
310
|
+
"tool": true,
|
|
311
|
+
"noun": "effect",
|
|
312
|
+
"verb": "check",
|
|
313
|
+
"title": "Check effect runs",
|
|
314
|
+
"description": "Check recorded background actions (effects), such as sending mail after a transaction commits. Reports runs marked failed after exhausting their attempts, runs waiting for a handler no plugin declares any more, and runs still pending past their due time by more than the server’s threshold (10 minutes by default). An overdue run can indicate that no process is running them, even while graph writes succeed. Does not retry or mark runs failed itself; with no effect records supported by the schema, reports no findings. Takes no arguments. Returns a report in content.body, with warning or failure findings when present; it does not repair the records or configuration.",
|
|
315
|
+
"input": {},
|
|
316
|
+
"readOnly": true
|
|
317
|
+
},
|
|
318
|
+
"effect_retry": {
|
|
319
|
+
"tool": true,
|
|
320
|
+
"destructive": false,
|
|
321
|
+
"noun": "effect",
|
|
322
|
+
"verb": "retry",
|
|
323
|
+
"title": "Retry failed effect runs",
|
|
324
|
+
"description": "Put failed effect runs back to pending with a fresh attempt allowance, so the pool works them again through its ordinary path: attempts, backoff and leases as for a new run. If the cause is fixed they finish; if not they fail again and the check reports them again. Takes a handler name or a single run. Touches only failed runs of a handler some plugin declares, and says how many.\n\n yak effect retry send_receipt",
|
|
325
|
+
"input": {
|
|
326
|
+
"of": {
|
|
327
|
+
"type": "string",
|
|
328
|
+
"description": "a handler name (all its failed runs) or one run's id"
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
"required": [
|
|
332
|
+
"of"
|
|
333
|
+
],
|
|
334
|
+
"positional": [
|
|
335
|
+
"of"
|
|
336
|
+
]
|
|
337
|
+
},
|
|
338
|
+
"effect_drop": {
|
|
339
|
+
"tool": true,
|
|
340
|
+
"noun": "effect",
|
|
341
|
+
"verb": "drop",
|
|
342
|
+
"title": "Drop failed effect runs",
|
|
343
|
+
"description": "Delete effect runs whose work no one owes any more, so the check stops reporting them: failed runs, and pending runs whose handler no plugin declares any more. Takes a handler name or a single run, and says how many.\n\n yak effect drop session_run",
|
|
344
|
+
"input": {
|
|
345
|
+
"of": {
|
|
346
|
+
"type": "string",
|
|
347
|
+
"description": "a handler name (all its failed runs) or one run's id"
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
"required": [
|
|
351
|
+
"of"
|
|
352
|
+
],
|
|
353
|
+
"positional": [
|
|
354
|
+
"of"
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"kinds": {
|
|
359
|
+
"lease": {
|
|
360
|
+
"$id": "urn:uuid:5ad53d0f-a5e0-41d8-a31e-31ade78c7be3",
|
|
361
|
+
"description": "a duty held by one process at a time — its eid is derived from `name`, so two processes reaching for the same duty address one row and the winner is settled by the graph's own precondition; plumbing between the processes on one store, so it is not history"
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
package/vocab.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The component declarations, and only those: the module exported as
|
|
2
|
+
// `@yaks/effects/vocab`. It imports no storage, no SQL and no runtime, so a
|
|
3
|
+
// browser tab that loads this vocabulary loads nothing else.
|
|
4
|
+
|
|
5
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
6
|
+
import { effectDoc } from './docs.js'
|
|
7
|
+
import { provisionalDoc } from './provisional.js'
|
|
8
|
+
import manifest from './package.json' with { type: 'json' }
|
|
9
|
+
|
|
10
|
+
export { effectDoc, provisionalDoc }
|
|
11
|
+
|
|
12
|
+
/** What this package is: its manifest's description, the one place it is
|
|
13
|
+
* written, which a host stamps on each document here. */
|
|
14
|
+
export let description: string = manifest.description
|
|
15
|
+
|
|
16
|
+
/** Every document this plugin declares — the pool's `effect` rows, which an
|
|
17
|
+
* application loads when effects are to be written down and worked by any
|
|
18
|
+
* process, the `lease` a duty is held under, and the `provisional` mark. A
|
|
19
|
+
* vocabulary that wants only the mark loads `provisionalDoc` instead. */
|
|
20
|
+
export let docs: VocabDoc[] = [effectDoc]
|