@yaks/tracker 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 (198) hide show
  1. package/Histogram.js +71 -0
  2. package/Histogram.js.map +1 -0
  3. package/Histogram.ts +100 -0
  4. package/LICENSE +202 -0
  5. package/README.md +639 -2
  6. package/_dist/brief.d.ts +25 -0
  7. package/_dist/brief.d.ts.map +1 -0
  8. package/_dist/changes.d.ts +9 -0
  9. package/_dist/changes.d.ts.map +1 -0
  10. package/_dist/chart.d.ts +24 -0
  11. package/_dist/chart.d.ts.map +1 -0
  12. package/_dist/digest.d.ts +64 -0
  13. package/_dist/digest.d.ts.map +1 -0
  14. package/_dist/effects.d.ts +73 -0
  15. package/_dist/effects.d.ts.map +1 -0
  16. package/_dist/errors.d.ts +14 -0
  17. package/_dist/errors.d.ts.map +1 -0
  18. package/_dist/everywhere.d.ts +13 -0
  19. package/_dist/everywhere.d.ts.map +1 -0
  20. package/_dist/fault.d.ts +29 -0
  21. package/_dist/fault.d.ts.map +1 -0
  22. package/_dist/file.d.ts +6 -0
  23. package/_dist/file.d.ts.map +1 -0
  24. package/_dist/fixtime.d.ts +20 -0
  25. package/_dist/fixtime.d.ts.map +1 -0
  26. package/_dist/frames.d.ts +6 -0
  27. package/_dist/frames.d.ts.map +1 -0
  28. package/_dist/graph.d.ts +3 -0
  29. package/_dist/graph.d.ts.map +1 -0
  30. package/_dist/group.d.ts +21 -0
  31. package/_dist/group.d.ts.map +1 -0
  32. package/_dist/instrument.d.ts +37 -0
  33. package/_dist/instrument.d.ts.map +1 -0
  34. package/_dist/intake.d.ts +21 -0
  35. package/_dist/intake.d.ts.map +1 -0
  36. package/_dist/merge.d.ts +11 -0
  37. package/_dist/merge.d.ts.map +1 -0
  38. package/_dist/mod.d.ts +7 -0
  39. package/_dist/mod.d.ts.map +1 -0
  40. package/_dist/model.d.ts +20 -0
  41. package/_dist/model.d.ts.map +1 -0
  42. package/_dist/outage.d.ts +7 -0
  43. package/_dist/outage.d.ts.map +1 -0
  44. package/_dist/people.d.ts +3 -0
  45. package/_dist/people.d.ts.map +1 -0
  46. package/_dist/poll.d.ts +101 -0
  47. package/_dist/poll.d.ts.map +1 -0
  48. package/_dist/poll_thread.d.ts +8 -0
  49. package/_dist/poll_thread.d.ts.map +1 -0
  50. package/_dist/reading.d.ts +34 -0
  51. package/_dist/reading.d.ts.map +1 -0
  52. package/_dist/remote.d.ts +61 -0
  53. package/_dist/remote.d.ts.map +1 -0
  54. package/_dist/report.d.ts +324 -0
  55. package/_dist/report.d.ts.map +1 -0
  56. package/_dist/resolution.d.ts +22 -0
  57. package/_dist/resolution.d.ts.map +1 -0
  58. package/_dist/routes.d.ts +33 -0
  59. package/_dist/routes.d.ts.map +1 -0
  60. package/_dist/script.d.ts +8 -0
  61. package/_dist/script.d.ts.map +1 -0
  62. package/_dist/service.d.ts +30 -0
  63. package/_dist/service.d.ts.map +1 -0
  64. package/_dist/sync_health.d.ts +4 -0
  65. package/_dist/sync_health.d.ts.map +1 -0
  66. package/_dist/ticket.d.ts +14 -0
  67. package/_dist/ticket.d.ts.map +1 -0
  68. package/_dist/tools.d.ts +39 -0
  69. package/_dist/tools.d.ts.map +1 -0
  70. package/_dist/trace-intake.d.ts +25 -0
  71. package/_dist/trace-intake.d.ts.map +1 -0
  72. package/_dist/views.d.ts +11 -0
  73. package/_dist/views.d.ts.map +1 -0
  74. package/_dist/vocab.d.ts +9 -0
  75. package/_dist/vocab.d.ts.map +1 -0
  76. package/box.json +51 -0
  77. package/brief.js +86 -0
  78. package/brief.js.map +1 -0
  79. package/brief.ts +120 -0
  80. package/changes.js +57 -0
  81. package/changes.js.map +1 -0
  82. package/changes.ts +70 -0
  83. package/chart.js +186 -0
  84. package/chart.js.map +1 -0
  85. package/chart.ts +193 -0
  86. package/deno.json +1 -0
  87. package/digest.js +329 -0
  88. package/digest.js.map +1 -0
  89. package/digest.ts +406 -0
  90. package/effects.js +136 -0
  91. package/effects.js.map +1 -0
  92. package/effects.ts +178 -0
  93. package/errors.js +130 -0
  94. package/errors.js.map +1 -0
  95. package/errors.ts +185 -0
  96. package/everywhere.js +46 -0
  97. package/everywhere.js.map +1 -0
  98. package/everywhere.ts +66 -0
  99. package/fault.js +65 -0
  100. package/fault.js.map +1 -0
  101. package/fault.ts +107 -0
  102. package/file.js +87 -0
  103. package/file.js.map +1 -0
  104. package/file.ts +93 -0
  105. package/fixtime.js +67 -0
  106. package/fixtime.js.map +1 -0
  107. package/fixtime.ts +86 -0
  108. package/frames.js +77 -0
  109. package/frames.js.map +1 -0
  110. package/frames.ts +69 -0
  111. package/graph.js +7 -0
  112. package/graph.js.map +1 -0
  113. package/graph.ts +8 -0
  114. package/group.js +444 -0
  115. package/group.js.map +1 -0
  116. package/group.ts +533 -0
  117. package/inspect.js +471 -0
  118. package/inspect.js.map +1 -0
  119. package/inspect.ts +693 -0
  120. package/instrument.js +69 -0
  121. package/instrument.js.map +1 -0
  122. package/instrument.ts +93 -0
  123. package/intake.js +43 -0
  124. package/intake.js.map +1 -0
  125. package/intake.ts +84 -0
  126. package/merge.js +126 -0
  127. package/merge.js.map +1 -0
  128. package/merge.ts +115 -0
  129. package/migrate.ts +36 -0
  130. package/mod.js +8 -0
  131. package/mod.js.map +1 -0
  132. package/mod.ts +19 -0
  133. package/model.js +8 -0
  134. package/model.js.map +1 -0
  135. package/model.ts +27 -0
  136. package/outage.js +129 -0
  137. package/outage.js.map +1 -0
  138. package/outage.ts +158 -0
  139. package/package.json +133 -4
  140. package/page.d.ts +2 -0
  141. package/page.js +905 -0
  142. package/people.js +51 -0
  143. package/people.js.map +1 -0
  144. package/people.ts +82 -0
  145. package/poll.js +277 -0
  146. package/poll.js.map +1 -0
  147. package/poll.ts +411 -0
  148. package/poll_thread.js +104 -0
  149. package/poll_thread.js.map +1 -0
  150. package/poll_thread.ts +126 -0
  151. package/poll_worker.ts +45 -0
  152. package/reading.js +122 -0
  153. package/reading.js.map +1 -0
  154. package/reading.ts +162 -0
  155. package/reconcile.js +113 -0
  156. package/reconcile.js.map +1 -0
  157. package/reconcile.ts +130 -0
  158. package/remote.js +312 -0
  159. package/remote.js.map +1 -0
  160. package/remote.ts +397 -0
  161. package/report.js +825 -0
  162. package/report.js.map +1 -0
  163. package/report.ts +944 -0
  164. package/resolution.js +114 -0
  165. package/resolution.js.map +1 -0
  166. package/resolution.ts +123 -0
  167. package/routes.js +130 -0
  168. package/routes.js.map +1 -0
  169. package/routes.ts +163 -0
  170. package/script.js +13 -0
  171. package/script.js.map +1 -0
  172. package/script.ts +16 -0
  173. package/service.js +174 -0
  174. package/service.js.map +1 -0
  175. package/service.ts +215 -0
  176. package/spread.js +94 -0
  177. package/spread.js.map +1 -0
  178. package/spread.ts +101 -0
  179. package/sync_health.js +36 -0
  180. package/sync_health.js.map +1 -0
  181. package/sync_health.ts +65 -0
  182. package/ticket.js +6 -0
  183. package/ticket.js.map +1 -0
  184. package/ticket.ts +24 -0
  185. package/tools.js +305 -0
  186. package/tools.js.map +1 -0
  187. package/tools.ts +411 -0
  188. package/trace-intake.js +164 -0
  189. package/trace-intake.js.map +1 -0
  190. package/trace-intake.ts +148 -0
  191. package/views.js +247 -0
  192. package/views.js.map +1 -0
  193. package/views.ts +254 -0
  194. package/vocab.js +20 -0
  195. package/vocab.js.map +1 -0
  196. package/vocab.json +834 -0
  197. package/vocab.ts +14 -0
  198. package/yak-tracker@.service +22 -0
package/instrument.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `@yaks/tracker/instrument` — a class whose every call runs inside a
3
+ * reporting boundary: its construction, and each method of its prototype,
4
+ * lifecycle callbacks and RPC alike. The boundary is given, so the class's
5
+ * failures are reported wherever the caller's tracker reports them, and a
6
+ * callback installed by construction keeps the invocation it was made in.
7
+ *
8
+ * ```ts
9
+ * import { instrument } from '@yaks/tracker/instrument'
10
+ * import { assertEquals } from '@std/assert'
11
+ *
12
+ * let entered: string[] = []
13
+ * class Shop {
14
+ * sell() {
15
+ * return 'sold'
16
+ * }
17
+ * }
18
+ * let Tracked = instrument(Shop, (_args, name, run) => {
19
+ * entered.push(name)
20
+ * return run()
21
+ * })
22
+ * assertEquals(new Tracked().sell(), 'sold')
23
+ * assertEquals(entered, ['Shop constructor', 'Shop sell'])
24
+ * ```
25
+ *
26
+ * @module
27
+ */ /** The boundary a call enters: the arguments its object was constructed
28
+ * with (a Durable Object's state and env), its name as `<Class> <method>`,
29
+ * the call, and the request it was handed, if any. It answers what the call
30
+ * answers. */ /** Each method an object of a class answers, its own and those it inherits,
31
+ * by the nearest definition: everything short of `Object`'s own. */ export let methods = (prototype)=>{
32
+ let found = new Map();
33
+ for(let at = prototype; at && at != Object.prototype; at = Object.getPrototypeOf(at)){
34
+ for (let name of Object.getOwnPropertyNames(at)){
35
+ let value = Object.getOwnPropertyDescriptor(at, name)?.value;
36
+ if (name == 'constructor' || found.has(name)) continue;
37
+ if (typeof value == 'function') found.set(name, value);
38
+ }
39
+ }
40
+ return [
41
+ ...found
42
+ ];
43
+ };
44
+ /** `Original`, with its construction and each of its prototype's methods run
45
+ * inside `enter`. `making`, when given, is told each construction's
46
+ * arguments and the class's name before the object is made. */ export let instrument = (Original, enter, making)=>{
47
+ let Base = Original;
48
+ let made = new WeakMap();
49
+ class Tracked extends Base {
50
+ }
51
+ for (let [method, run] of methods(Base.prototype)){
52
+ Object.defineProperty(Tracked.prototype, method, {
53
+ value (...args) {
54
+ return enter(made.get(this) ?? [], `${Base.name} ${method}`, ()=>Reflect.apply(run, this, args), args.find((arg)=>arg instanceof Request));
55
+ }
56
+ });
57
+ }
58
+ return new Proxy(Tracked, {
59
+ construct (target, args, newTarget) {
60
+ making?.(args, Base.name);
61
+ return enter(args, `${Base.name} constructor`, ()=>{
62
+ let object = Reflect.construct(target, args, newTarget);
63
+ made.set(object, args);
64
+ return object;
65
+ });
66
+ }
67
+ });
68
+ };
69
+ //# sourceMappingURL=instrument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrument.js","sources":["./instrument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GAED;;;YAGY,GAUZ;kEACkE,GAClE,OAAO,IAAI,UAAU,CAAC;EACpB,IAAI,QAAQ,IAAI;EAChB,IACE,IAAI,KAAK,WACT,MAAM,MAAM,OAAO,SAAS,EAC5B,KAAK,OAAO,cAAc,CAAC,IAC3B;IACA,KAAK,IAAI,QAAQ,OAAO,mBAAmB,CAAC,IAAK;MAC/C,IAAI,QAAQ,OAAO,wBAAwB,CAAC,IAAI,OAAO;MACvD,IAAI,QAAQ,iBAAiB,MAAM,GAAG,CAAC,OAAO;MAC9C,IAAI,OAAO,SAAS,YAAY,MAAM,GAAG,CAAC,MAAM;IAClD;EACF;EACA,OAAO;OAAI;GAAM;AACnB,EAAC;AAED;;6DAE6D,GAC7D,OAAO,IAAI,aAAa,CACtB,UACA,OACA;EAEA,IAAI,OAAO;EACX,IAAI,OAAO,IAAI;EACf,MAAM,gBAAgB;EAAM;EAC5B,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAG;IACjD,OAAO,cAAc,CAAC,QAAQ,SAAS,EAAE,QAAQ;MAC/C,OAAoB,GAAG,IAAe;QACpC,OAAO,MACL,KAAK,GAAG,CAAC,IAAI,KAAK,EAAE,EACpB,GAAG,KAAK,IAAI,CAAC,CAAC,EAAE,QAAQ,EACxB,IAAM,QAAQ,KAAK,CAAC,KAAK,IAAI,EAAE,OAC/B,KAAK,IAAI,CAAC,CAAC,MAAwB,eAAe;MAEtD;IACF;EACF;EACA,OAAO,IAAI,MAAM,SAAS;IACxB,WAAU,MAAM,EAAE,IAAI,EAAE,SAAS;MAC/B,SAAS,MAAM,KAAK,IAAI;MACxB,OAAO,MAAM,MAAM,GAAG,KAAK,IAAI,CAAC,YAAY,CAAC,EAAE;QAC7C,IAAI,SAAS,QAAQ,SAAS,CAAC,QAAQ,MAAM;QAC7C,KAAK,GAAG,CAAC,QAAQ;QACjB,OAAO;MACT;IACF;EACF;AACF,EAAC"}
package/instrument.ts ADDED
@@ -0,0 +1,93 @@
1
+ /**
2
+ * `@yaks/tracker/instrument` — a class whose every call runs inside a
3
+ * reporting boundary: its construction, and each method of its prototype,
4
+ * lifecycle callbacks and RPC alike. The boundary is given, so the class's
5
+ * failures are reported wherever the caller's tracker reports them, and a
6
+ * callback installed by construction keeps the invocation it was made in.
7
+ *
8
+ * ```ts
9
+ * import { instrument } from '@yaks/tracker/instrument'
10
+ * import { assertEquals } from '@std/assert'
11
+ *
12
+ * let entered: string[] = []
13
+ * class Shop {
14
+ * sell() {
15
+ * return 'sold'
16
+ * }
17
+ * }
18
+ * let Tracked = instrument(Shop, (_args, name, run) => {
19
+ * entered.push(name)
20
+ * return run()
21
+ * })
22
+ * assertEquals(new Tracked().sell(), 'sold')
23
+ * assertEquals(entered, ['Shop constructor', 'Shop sell'])
24
+ * ```
25
+ *
26
+ * @module
27
+ */
28
+
29
+ /** The boundary a call enters: the arguments its object was constructed
30
+ * with (a Durable Object's state and env), its name as `<Class> <method>`,
31
+ * the call, and the request it was handed, if any. It answers what the call
32
+ * answers. */
33
+ export type Enter = <T>(
34
+ args: unknown[],
35
+ name: string,
36
+ run: () => T,
37
+ request?: Request,
38
+ ) => T
39
+
40
+ type Method = (...args: unknown[]) => unknown
41
+
42
+ /** Each method an object of a class answers, its own and those it inherits,
43
+ * by the nearest definition: everything short of `Object`'s own. */
44
+ export let methods = (prototype: object): [string, Method][] => {
45
+ let found = new Map<string, Method>()
46
+ for (
47
+ let at = prototype;
48
+ at && at != Object.prototype;
49
+ at = Object.getPrototypeOf(at)
50
+ ) {
51
+ for (let name of Object.getOwnPropertyNames(at)) {
52
+ let value = Object.getOwnPropertyDescriptor(at, name)?.value
53
+ if (name == 'constructor' || found.has(name)) continue
54
+ if (typeof value == 'function') found.set(name, value)
55
+ }
56
+ }
57
+ return [...found]
58
+ }
59
+
60
+ /** `Original`, with its construction and each of its prototype's methods run
61
+ * inside `enter`. `making`, when given, is told each construction's
62
+ * arguments and the class's name before the object is made. */
63
+ export let instrument = <C>(
64
+ Original: C,
65
+ enter: Enter,
66
+ making?: (args: unknown[], name: string) => void,
67
+ ): C => {
68
+ let Base = Original as unknown as new (...args: unknown[]) => object
69
+ let made = new WeakMap<object, unknown[]>()
70
+ class Tracked extends Base {}
71
+ for (let [method, run] of methods(Base.prototype)) {
72
+ Object.defineProperty(Tracked.prototype, method, {
73
+ value(this: object, ...args: unknown[]) {
74
+ return enter(
75
+ made.get(this) ?? [],
76
+ `${Base.name} ${method}`,
77
+ () => Reflect.apply(run, this, args),
78
+ args.find((arg): arg is Request => arg instanceof Request),
79
+ )
80
+ },
81
+ })
82
+ }
83
+ return new Proxy(Tracked, {
84
+ construct(target, args, newTarget) {
85
+ making?.(args, Base.name)
86
+ return enter(args, `${Base.name} constructor`, () => {
87
+ let object = Reflect.construct(target, args, newTarget)
88
+ made.set(object, args)
89
+ return object
90
+ })
91
+ },
92
+ }) as unknown as C
93
+ }
package/intake.js ADDED
@@ -0,0 +1,43 @@
1
+ // Intake keeps every immutable reporter bundle once. Grouping adds its receipt
2
+ // to that same occurrence; retention can later move it into recoverable trash.
3
+ import { Refused } from "@yaks/graph/errors";
4
+ export let ingest = async (g, rows)=>{
5
+ let unique = [
6
+ ...new Map(rows.map((row)=>[
7
+ row.entity.eid,
8
+ row
9
+ ])).values()
10
+ ];
11
+ // References can mint bare entity spines before a queued record arrives.
12
+ // A redelivery must preserve grouping's receipt, including one in trash.
13
+ let known = new Set((await g.get(unique.map((row)=>row.entity.eid))).filter((row)=>Object.keys(row).some((name)=>name != 'entity')).map((row)=>row.entity.eid));
14
+ let fresh = unique.filter((row)=>!known.has(row.entity.eid));
15
+ if (fresh.length) await g.apply(fresh, {
16
+ trusted: true
17
+ });
18
+ };
19
+ /** Passes over a source, each failure contained to its own record, then throws
20
+ * what failed. A record the graph refuses is set aside (`refuse`); one that
21
+ * failed otherwise (a locked database) stays and is offered again next pass.
22
+ * Nothing behind a failing record waits for it. */ export let each = async (source, stop, work)=>{
23
+ let failed = [];
24
+ for await (let record of source()){
25
+ if (stop?.aborted) break;
26
+ try {
27
+ await work(record);
28
+ } catch (error) {
29
+ failed.push(error);
30
+ if (error instanceof Refused) await record.refuse?.();
31
+ }
32
+ }
33
+ if (failed.length == 1) throw failed[0];
34
+ if (failed.length) throw new AggregateError(failed, `${failed.length} failed`);
35
+ };
36
+ /** Every complete record, admitted then acknowledged. A `stop` that aborts
37
+ * ends it between records: the one in hand is committed and acknowledged, and
38
+ * the rest stay in the source for the next intake. */ export let intake = (g, source, stop)=>each(source, stop, async (record)=>{
39
+ await ingest(g, record.rows);
40
+ await record.ack();
41
+ });
42
+ export { reserveTrace, TRACE_CEILING, TRACE_MAX_BUNDLES, TRACE_RESERVATION_WRITES, TRACE_ROW_BOUND, traceBatch, traceBudget } from "./trace-intake.js";
43
+ //# sourceMappingURL=intake.js.map
package/intake.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intake.js","sources":["./intake.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+EAA+E;AAG/E,SAAS,OAAO,kCAAuC;AAcvD,OAAO,IAAI,SAAS,OAClB,GACA;EAEA,IAAI,SAAS;OAAI,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,MAAQ;QAAC,IAAI,MAAM,CAAC,GAAG;QAAE;OAAI,GAAG,MAAM;GAAG;EAC5E,yEAAyE;EACzE,yEAAyE;EACzE,IAAI,QAAQ,IAAI,IACd,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,MAAQ,IAAI,MAAM,CAAC,GAAG,EAAE,EAC9C,MAAM,CAAC,CAAC,MAAQ,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,OAAS,QAAQ,WACxD,GAAG,CAAC,CAAC,MAAQ,IAAI,MAAM,CAAC,GAAG;EAEhC,IAAI,QAAQ,OAAO,MAAM,CAAC,CAAC,MAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG;EAC5D,IAAI,MAAM,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO;IAAE,SAAS;EAAK;AACzD,EAAC;AAED;;;iDAGiD,GACjD,OAAO,IAAI,OAAO,OAChB,QACA,MACA;EAEA,IAAI,SAAoB,EAAE;EAC1B,WAAW,IAAI,UAAU,SAAU;IACjC,IAAI,MAAM,SAAS;IACnB,IAAI;MACF,MAAM,KAAK;IACb,EAAE,OAAO,OAAO;MACd,OAAO,IAAI,CAAC;MACZ,IAAI,iBAAiB,SAAS,MAAM,OAAO,MAAM;IACnD;EACF;EACA,IAAI,OAAO,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,EAAE;EACvC,IAAI,OAAO,MAAM,EAAE,MAAM,IAAI,eAAe,QAAQ,GAAG,OAAO,MAAM,CAAC,OAAO,CAAC;AAC/E,EAAC;AAED;;oDAEoD,GACpD,OAAO,IAAI,SAAS,CAClB,GACA,QACA,OAEA,KAAK,QAAQ,MAAM,OAAO;IACxB,MAAM,OAAO,GAAG,OAAO,IAAI;IAC3B,MAAM,OAAO,GAAG;EAClB,GAAE;AAEJ,SACE,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,UAAU,EACV,WAAW,4BACa"}
package/intake.ts ADDED
@@ -0,0 +1,84 @@
1
+ // Intake keeps every immutable reporter bundle once. Grouping adds its receipt
2
+ // to that same occurrence; retention can later move it into recoverable trash.
3
+
4
+ import type { Bundle, Graph } from 'jsr:@yaks/graph@0.2.36'
5
+ import { Refused } from '@yaks/graph/errors'
6
+
7
+ export type Record = {
8
+ rows: Bundle[]
9
+ ack: () => void | Promise<void>
10
+ /** A durable local receipt, retained until remote delivery is acknowledged. */
11
+ admitted?: boolean
12
+ admit?: () => void | Promise<void>
13
+ /** Sets the record aside, kept but no longer offered, once the graph
14
+ * refuses it for good: retrying a refusal can never succeed. */
15
+ refuse?: () => void | Promise<void>
16
+ }
17
+ export type Source = () => AsyncIterable<Record>
18
+
19
+ export let ingest = async (
20
+ g: Graph,
21
+ rows: Bundle[],
22
+ ): Promise<void> => {
23
+ let unique = [...new Map(rows.map((row) => [row.entity.eid, row])).values()]
24
+ // References can mint bare entity spines before a queued record arrives.
25
+ // A redelivery must preserve grouping's receipt, including one in trash.
26
+ let known = new Set(
27
+ (await g.get(unique.map((row) => row.entity.eid)))
28
+ .filter((row) => Object.keys(row).some((name) => name != 'entity'))
29
+ .map((row) => row.entity.eid),
30
+ )
31
+ let fresh = unique.filter((row) => !known.has(row.entity.eid))
32
+ if (fresh.length) await g.apply(fresh, { trusted: true })
33
+ }
34
+
35
+ /** Passes over a source, each failure contained to its own record, then throws
36
+ * what failed. A record the graph refuses is set aside (`refuse`); one that
37
+ * failed otherwise (a locked database) stays and is offered again next pass.
38
+ * Nothing behind a failing record waits for it. */
39
+ export let each = async (
40
+ source: Source,
41
+ stop: AbortSignal | undefined,
42
+ work: (record: Record) => Promise<void>,
43
+ ): Promise<void> => {
44
+ let failed: unknown[] = []
45
+ for await (let record of source()) {
46
+ if (stop?.aborted) break
47
+ try {
48
+ await work(record)
49
+ } catch (error) {
50
+ failed.push(error)
51
+ if (error instanceof Refused) await record.refuse?.()
52
+ }
53
+ }
54
+ if (failed.length == 1) throw failed[0]
55
+ if (failed.length) throw new AggregateError(failed, `${failed.length} failed`)
56
+ }
57
+
58
+ /** Every complete record, admitted then acknowledged. A `stop` that aborts
59
+ * ends it between records: the one in hand is committed and acknowledged, and
60
+ * the rest stay in the source for the next intake. */
61
+ export let intake = (
62
+ g: Graph,
63
+ source: Source,
64
+ stop?: AbortSignal,
65
+ ): Promise<void> =>
66
+ each(source, stop, async (record) => {
67
+ await ingest(g, record.rows)
68
+ await record.ack()
69
+ })
70
+
71
+ export {
72
+ reserveTrace,
73
+ TRACE_CEILING,
74
+ TRACE_MAX_BUNDLES,
75
+ TRACE_RESERVATION_WRITES,
76
+ TRACE_ROW_BOUND,
77
+ traceBatch,
78
+ traceBudget,
79
+ } from './trace-intake.js'
80
+ export type {
81
+ TraceBatch,
82
+ TraceBudget,
83
+ TraceReservation,
84
+ } from './trace-intake.js'
package/merge.js ADDED
@@ -0,0 +1,126 @@
1
+ // Consolidation keeps issued identities, historical counts and capture bytes.
2
+ import { line } from "@yaks/query";
3
+ import { Stale } from "@yaks/graph/errors";
4
+ import { token } from "@yaks/graph/sha256";
5
+ import { comp, str } from "./model.js";
6
+ import { stablePlace } from "./fault.js";
7
+ import { trim } from "./group.js";
8
+ /** Follow a consolidated identity at the same boundary that reads its entity. */ export let survivor = async (g, eid)=>{
9
+ let seen = new Set();
10
+ while(!seen.has(eid)){
11
+ seen.add(eid);
12
+ let [row] = await g.get([
13
+ eid
14
+ ]);
15
+ let into = str(comp(row, 'merged').into);
16
+ if (!into) return row;
17
+ eid = into;
18
+ }
19
+ throw Error(`merged identities form a cycle at ${eid}`);
20
+ };
21
+ let guard = (row)=>Object.fromEntries([
22
+ 'bug',
23
+ 'resolved',
24
+ 'archived',
25
+ 'notified',
26
+ 'taken'
27
+ ].map((name)=>[
28
+ name,
29
+ Object.fromEntries((name == 'bug' ? [
30
+ 'fault',
31
+ 'hits',
32
+ 'first',
33
+ 'last'
34
+ ] : [
35
+ 'at'
36
+ ]).map((key)=>[
37
+ key,
38
+ token(comp(row, name)[key])
39
+ ]))
40
+ ]));
41
+ let first = (row)=>str(comp(row, 'bug').first);
42
+ let rank = (row)=>row.archived ? 2 : row.resolved ? 1 : 0;
43
+ let ordered = (rows)=>rows.toSorted((a, b)=>rank(a) - rank(b) || first(a).localeCompare(first(b)) || a.entity.eid.localeCompare(b.entity.eid));
44
+ /** One transaction per equivalent fault, including its occurrence receipts.
45
+ * Prefer an open group, so consolidation never resolves or reopens a failure.
46
+ * The survivor keeps its own resolution, task and correspondence. */ export let consolidation = (rows, errors)=>{
47
+ let [kept, ...rest] = ordered(rows);
48
+ let held = comp(kept, 'bug');
49
+ let fault = stablePlace(str(held.fault));
50
+ let notified = kept.notified ?? rows.find((r)=>r.notified)?.notified;
51
+ return [
52
+ {
53
+ entity: kept.entity,
54
+ $was: guard(kept),
55
+ bug: {
56
+ fault,
57
+ spot: stablePlace(str(held.spot)) || null,
58
+ hits: rows.reduce((n, r)=>n + Number(comp(r, 'bug').hits ?? 0), 0),
59
+ first: rows.map(first).sort()[0],
60
+ last: rows.map((r)=>str(comp(r, 'bug').last)).sort().at(-1)
61
+ },
62
+ ...notified ? {
63
+ notified
64
+ } : {}
65
+ },
66
+ ...rest.map((row)=>({
67
+ entity: row.entity,
68
+ $was: guard(row),
69
+ bug: null,
70
+ merged: {
71
+ into: kept.entity.eid
72
+ }
73
+ })),
74
+ ...errors.map((row)=>({
75
+ entity: row.entity,
76
+ $was: {
77
+ error: {
78
+ bug: token(comp(row, 'error').bug)
79
+ }
80
+ },
81
+ error: {
82
+ fault,
83
+ bug: kept.entity.eid
84
+ }
85
+ }))
86
+ ];
87
+ };
88
+ /** Repair groups whose only difference was a bundle's content hash. */ export let regroup = async (g)=>{
89
+ let rows = await g.read('.bug *');
90
+ let groups = new Map();
91
+ for (let row of rows){
92
+ let b = comp(row, 'bug');
93
+ let key = JSON.stringify([
94
+ b.app ?? '',
95
+ stablePlace(str(b.fault))
96
+ ]);
97
+ groups.set(key, [
98
+ ...groups.get(key) ?? [],
99
+ row
100
+ ]);
101
+ }
102
+ let bugs = 0, merged = 0;
103
+ for (let rows of groups.values()){
104
+ if (!rows.some((r)=>stablePlace(str(comp(r, 'bug').fault)) != comp(r, 'bug').fault)) continue;
105
+ let errors = (await Promise.all(rows.map((r)=>g.read(line`.error.bug=${r.entity.eid} *`)))).flat();
106
+ try {
107
+ let patch = consolidation(rows, errors);
108
+ await g.apply(patch, {
109
+ trusted: true
110
+ });
111
+ await trim(g, patch[0].entity.eid);
112
+ bugs++;
113
+ merged += rows.length - 1;
114
+ } catch (error) {
115
+ // A concurrent capture keeps every receipt; the next pass reads it anew.
116
+ if (!(error instanceof Stale)) {
117
+ throw error;
118
+ }
119
+ }
120
+ }
121
+ return {
122
+ bugs,
123
+ merged
124
+ };
125
+ };
126
+ //# sourceMappingURL=merge.js.map
package/merge.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sources":["./merge.ts"],"names":[],"mappings":"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"}
package/merge.ts ADDED
@@ -0,0 +1,115 @@
1
+ // Consolidation keeps issued identities, historical counts and capture bytes.
2
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
3
+ import { line } from '@yaks/query'
4
+ import { Stale } from '@yaks/graph/errors'
5
+ import { token } from '@yaks/graph/sha256'
6
+ import { comp, type Desk, str } from './model.js'
7
+ import { stablePlace } from './fault.js'
8
+ import { trim } from './group.js'
9
+
10
+ /** Follow a consolidated identity at the same boundary that reads its entity. */
11
+ export let survivor = async (
12
+ g: Pick<Desk, 'get'>,
13
+ eid: string,
14
+ ): Promise<Bundle | undefined> => {
15
+ let seen = new Set<string>()
16
+ while (!seen.has(eid)) {
17
+ seen.add(eid)
18
+ let [row] = await g.get([eid])
19
+ let into = str(comp(row, 'merged').into)
20
+ if (!into) return row
21
+ eid = into
22
+ }
23
+ throw Error(`merged identities form a cycle at ${eid}`)
24
+ }
25
+
26
+ let guard = (row: Bundle) =>
27
+ Object.fromEntries(
28
+ ['bug', 'resolved', 'archived', 'notified', 'taken'].map((name) => [
29
+ name,
30
+ Object.fromEntries(
31
+ (name == 'bug' ? ['fault', 'hits', 'first', 'last'] : ['at']).map((
32
+ key,
33
+ ) => [key, token(comp(row, name)[key])]),
34
+ ),
35
+ ]),
36
+ )
37
+ let first = (row: Bundle) => str(comp(row, 'bug').first)
38
+ let rank = (row: Bundle) => row.archived ? 2 : row.resolved ? 1 : 0
39
+ let ordered = (rows: Bundle[]) =>
40
+ rows.toSorted((a, b) =>
41
+ rank(a) - rank(b) || first(a).localeCompare(first(b)) ||
42
+ a.entity.eid.localeCompare(b.entity.eid)
43
+ )
44
+
45
+ /** One transaction per equivalent fault, including its occurrence receipts.
46
+ * Prefer an open group, so consolidation never resolves or reopens a failure.
47
+ * The survivor keeps its own resolution, task and correspondence. */
48
+ export let consolidation = (rows: Bundle[], errors: Bundle[]): Bundle[] => {
49
+ let [kept, ...rest] = ordered(rows)
50
+ let held = comp(kept, 'bug')
51
+ let fault = stablePlace(str(held.fault))
52
+ let notified = kept.notified ?? rows.find((r) => r.notified)?.notified
53
+ return [
54
+ {
55
+ entity: kept.entity,
56
+ $was: guard(kept),
57
+ bug: {
58
+ fault,
59
+ spot: stablePlace(str(held.spot)) || null,
60
+ hits: rows.reduce((n, r) => n + Number(comp(r, 'bug').hits ?? 0), 0),
61
+ first: rows.map(first).sort()[0],
62
+ last: rows.map((r) => str(comp(r, 'bug').last)).sort().at(-1),
63
+ },
64
+ ...notified ? { notified } : {},
65
+ },
66
+ ...rest.map((row): Bundle => ({
67
+ entity: row.entity,
68
+ $was: guard(row),
69
+ bug: null,
70
+ merged: { into: kept.entity.eid },
71
+ })),
72
+ ...errors.map((row): Bundle => ({
73
+ entity: row.entity,
74
+ $was: { error: { bug: token(comp(row, 'error').bug) } },
75
+ error: { fault, bug: kept.entity.eid },
76
+ })),
77
+ ]
78
+ }
79
+
80
+ /** Repair groups whose only difference was a bundle's content hash. */
81
+ export let regroup = async (
82
+ g: Desk,
83
+ ): Promise<{ bugs: number; merged: number }> => {
84
+ let rows = await g.read('.bug *')
85
+ let groups = new Map<string, Bundle[]>()
86
+ for (let row of rows) {
87
+ let b = comp(row, 'bug')
88
+ let key = JSON.stringify([b.app ?? '', stablePlace(str(b.fault))])
89
+ groups.set(key, [...groups.get(key) ?? [], row])
90
+ }
91
+ let bugs = 0, merged = 0
92
+ for (let rows of groups.values()) {
93
+ if (
94
+ !rows.some((r) =>
95
+ stablePlace(str(comp(r, 'bug').fault)) != comp(r, 'bug').fault
96
+ )
97
+ ) continue
98
+ let errors = (await Promise.all(rows.map((r) =>
99
+ g.read(line`.error.bug=${r.entity.eid} *`)
100
+ ))).flat()
101
+ try {
102
+ let patch = consolidation(rows, errors)
103
+ await g.apply(patch, { trusted: true })
104
+ await trim(g, patch[0].entity.eid)
105
+ bugs++
106
+ merged += rows.length - 1
107
+ } catch (error) {
108
+ // A concurrent capture keeps every receipt; the next pass reads it anew.
109
+ if (!(error instanceof Stale)) {
110
+ throw error
111
+ }
112
+ }
113
+ }
114
+ return { bugs, merged }
115
+ }
package/migrate.ts ADDED
@@ -0,0 +1,36 @@
1
+ // The box transition reads the retired title only while moving it to doc.
2
+ // Guards preserve a concurrent edit; a conflicting human title stops, never
3
+ // discards either value. This module is not imported by the running tracker.
4
+ import type { Graph } from 'jsr:@yaks/graph@0.2.36'
5
+ import { line } from 'jsr:@yaks/query@0.2.36'
6
+ import { token } from 'jsr:@yaks/graph@0.2.36/sha256'
7
+ import { comp, str, title } from './model.ts'
8
+
9
+ export let migrateTitles = async (g: Graph): Promise<number> => {
10
+ let rows = await g.read('.bug *')
11
+ let patches = []
12
+ for (let row of rows) {
13
+ let old = comp(row, 'bug').title
14
+ let held = comp(row, 'doc').title
15
+ if (old != null && held && old != held) {
16
+ throw new Error(`conflicting titles on ${row.entity.eid}; neither moved`)
17
+ }
18
+ if (old == null && held) continue
19
+ let occurrences = !old && !held
20
+ ? await g.read(
21
+ line`.error.bug=${row.entity.eid} * .order=error.at .limit=1`,
22
+ )
23
+ : []
24
+ patches.push({
25
+ entity: row.entity,
26
+ $was: { bug: { title: token(old) }, doc: { title: token(held) } },
27
+ doc: {
28
+ title: str(held || old) || (occurrences[0] && title(occurrences[0])) ||
29
+ str(comp(row, 'bug').fault),
30
+ },
31
+ bug: { title: null },
32
+ })
33
+ }
34
+ if (patches.length) await g.apply(patches, { trusted: true })
35
+ return patches.length
36
+ }
package/mod.js ADDED
@@ -0,0 +1,8 @@
1
+ // Tracker's portable core: vocabulary, grouping and retention. Runtime sinks
2
+ // and effects are separate facets so a browser does not load a box service.
3
+ export { bugDoc, trackerDoc } from "./vocab.js";
4
+ export { faultKey, faultOf, normalize } from "./fault.js";
5
+ export { bugEid, group, grouped, regresses, release, retained, trim } from "./group.js";
6
+ export { enrichFrames, stackFrames } from "./frames.js";
7
+ export { remoteBug, reopened } from "./reading.js";
8
+ //# sourceMappingURL=mod.js.map
package/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAE5E,SAAS,MAAM,EAAE,UAAU,qBAAoB;AAC/C,SAAS,QAAQ,EAAE,OAAO,EAAE,SAAS,qBAAoB;AACzD,SACE,MAAM,EAEN,KAAK,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,QAAQ,EACR,IAAI,qBACa;AAGnB,SAAS,YAAY,EAAgB,WAAW,sBAAqB;AACrE,SAAS,SAAS,EAAE,QAAQ,uBAAsB"}
package/mod.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Tracker's portable core: vocabulary, grouping and retention. Runtime sinks
2
+ // and effects are separate facets so a browser does not load a box service.
3
+
4
+ export { bugDoc, trackerDoc } from './vocab.js'
5
+ export { faultKey, faultOf, normalize } from './fault.js'
6
+ export {
7
+ bugEid,
8
+ type Enrich,
9
+ group,
10
+ grouped,
11
+ regresses,
12
+ release,
13
+ retained,
14
+ trim,
15
+ } from './group.js'
16
+ export { type Crumb, type Frame, type Level } from './model.js'
17
+
18
+ export { enrichFrames, type Resolve, stackFrames } from './frames.js'
19
+ export { remoteBug, reopened } from './reading.js'
package/model.js ADDED
@@ -0,0 +1,8 @@
1
+ // Tracker records are ordinary graph bundles; the helpers read that boundary.
2
+ export let comp = (row, name)=>row?.[name] && typeof row[name] == 'object' ? row[name] : {};
3
+ export let str = (value)=>value == null ? '' : String(value);
4
+ export let title = (row)=>{
5
+ let x = comp(row, 'exception');
6
+ return x.type ? `${x.type}: ${str(x.value)}` : str(comp(row, 'error').message);
7
+ };
8
+ //# sourceMappingURL=model.js.map
package/model.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sources":["./model.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAoB9E,OAAO,IAAI,OAAO,CAAC,KAAyB,OAC1C,KAAK,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK,IAAI,WAAW,GAAG,CAAC,KAAK,GAAW,CAAC,EAAC;AACtE,OAAO,IAAI,MAAM,CAAC,QAA2B,SAAS,OAAO,KAAK,OAAO,OAAM;AAC/E,OAAO,IAAI,QAAQ,CAAC;EAClB,IAAI,IAAI,KAAK,KAAK;EAClB,OAAO,EAAE,IAAI,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,GAAG,GAAG,IAAI,KAAK,KAAK,SAAS,OAAO;AAC/E,EAAC"}
package/model.ts ADDED
@@ -0,0 +1,27 @@
1
+ // Tracker records are ordinary graph bundles; the helpers read that boundary.
2
+
3
+ import type { Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
4
+
5
+ /** The part of a graph the tracker's handlers read and write through: a
6
+ * bug's grouping, its frames and its letters. */
7
+ export type Desk = Pick<Graph, 'vocab' | 'get' | 'read' | 'apply'>
8
+ export type Level = 'fatal' | 'error' | 'warning'
9
+ /** A mark a fixer or a resolution puts on a bug. */
10
+ export type Mark = 'taken' | 'resolved' | 'archived'
11
+ export type Frame = {
12
+ file: string
13
+ line?: number
14
+ column?: number
15
+ function?: string
16
+ app?: boolean
17
+ module?: string
18
+ symbol?: string
19
+ }
20
+ export type Crumb = { at: string; category: string; message: string }
21
+ export let comp = (row: Bundle | undefined, name: string): Comp =>
22
+ row?.[name] && typeof row[name] == 'object' ? row[name] as Comp : {}
23
+ export let str = (value: unknown): string => value == null ? '' : String(value)
24
+ export let title = (row: Bundle): string => {
25
+ let x = comp(row, 'exception')
26
+ return x.type ? `${x.type}: ${str(x.value)}` : str(comp(row, 'error').message)
27
+ }