@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/reading.js ADDED
@@ -0,0 +1,122 @@
1
+ // How a bug and an error read, whatever draws them: the whole message, where
2
+ // it happened, whether it is still broken, and the queries a page asks.
3
+ import { derivedEid } from "@yaks/graph/identity";
4
+ import { and, eq, every, line, order, querySearch } from "@yaks/query";
5
+ import { comp, str, title } from "./model.js";
6
+ import { place, sha, spot } from "./brief.js";
7
+ /** Worst first is historical occurrence count, not the retained sample size. */ export let openBugs = line`.bug.status=open * .order=-bug.hits`;
8
+ /** A bug's retained occurrences, newest first, as the query line a page asks. */ export let occurrences = (eid)=>line`.error.bug=${eid} * .order=-error.at`;
9
+ /** The same occurrences as a tree, for a read that need not parse a line that
10
+ * changes with every bug.
11
+ *
12
+ * ```ts
13
+ * import { equal } from '@yaks/testing'
14
+ * import { parse } from '@yaks/query'
15
+ * equal(occurring('b'), parse(occurrences('b')))
16
+ * ```
17
+ */ export let occurring = (eid)=>and(eq('error.bug', eid), every(), order('-error.at'));
18
+ /** The platform tracker's global eid: the scope a read names by default. */ export let platform = derivedEid('tracker|platform');
19
+ /** A bug's page on the box's tracker web when it lives on another side (the
20
+ * platform tracker, `yaks.app`), read through by global eid. A space's
21
+ * tracker holds its own bugs, so its page names that tracker's `scope`; one
22
+ * of the bug's occurrences opens on the same page.
23
+ *
24
+ * ```ts
25
+ * import { assertEquals } from '@std/assert'
26
+ * assertEquals(
27
+ * remoteBug('yaks.app', 'b', { error: 'e' }),
28
+ * '/?.bug&side=yaks.app&bug=b&error=e',
29
+ * )
30
+ * assertEquals(
31
+ * remoteBug('yaks.app', 'b', { scope: 's' }),
32
+ * '/?.bug&side=yaks.app&scope=s&bug=b',
33
+ * )
34
+ * assertEquals(
35
+ * remoteBug('yaks.app', 'b', { scope: platform }),
36
+ * '/?.bug&side=yaks.app&bug=b',
37
+ * )
38
+ * ```
39
+ */ export let remoteBug = (side, bug, { scope, error } = {})=>`/${querySearch('.bug', {
40
+ side,
41
+ ...scope && scope != platform ? {
42
+ scope
43
+ } : {},
44
+ bug,
45
+ ...error ? {
46
+ error
47
+ } : {}
48
+ })}`;
49
+ /** The whole message a bug or an error says. */ export let said = (e)=>e.bug ? str(comp(e, 'doc').title) : title(e);
50
+ /// let bug = { entity: { eid: 'b' }, bug: {}, doc: { title: 'Error: first' } }
51
+ /// let back = (regressed: object) => ({ ...bug, regressed })
52
+ /// reopened(back({ message: 'Error: again\n at f', commit: 'a'.repeat(40) })) -> 'Error: again (aaaaaaa)'
53
+ /// reopened(back({ message: 'Error: red (aaaaaaa1b) https://ci/1', commit: 'a'.repeat(7) + '1b' + 'c'.repeat(31) })) -> 'Error: red (aaaaaaa1b) https://ci/1'
54
+ /// reopened(back({ message: 'Error: busy', commit: 'dafb20d7-a68f-4f8c-8393-9c038d0f854c' })) -> 'Error: busy (version dafb20d7)'
55
+ /// reopened(back({})) -> 'Error: first'
56
+ /** The hit that reopened a bug, in a line: its message and the code it ran
57
+ * on. A bug reopened before its mark said so reads as its title. */ export let reopened = (bug)=>{
58
+ let back = comp(bug, 'regressed');
59
+ let line = (str(back.message) || said(bug)).split('\n')[0];
60
+ let code = ran(str(back.commit));
61
+ return code && !line.includes(code) ? `${line} (${code})` : line;
62
+ };
63
+ /** The code a hit ran on, as people say it. A Worker reports its deployment's
64
+ * version, a UUID: said whole beside a bug, it reads as the bug's own id. */ let ran = (commit)=>/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(commit) ? `version ${commit.slice(0, 8)}` : sha(commit);
65
+ /** Where a bug is open, resolved or archived; regressed is open again. */ export let standing = (e)=>str(comp(e, 'bug').status) || (e.archived ? 'archived' : e.resolved ? 'resolved' : 'open');
66
+ /** The dot a bug's standing wears: what is broken is a negative disc. */ export let pip = (e)=>({
67
+ open: e.regressed ? [
68
+ 'alert',
69
+ 'negative'
70
+ ] : [
71
+ 'negative'
72
+ ],
73
+ resolved: [
74
+ 'check',
75
+ 'positive'
76
+ ],
77
+ archived: [
78
+ 'ring'
79
+ ]
80
+ })[standing(e)] ?? [
81
+ 'ring'
82
+ ];
83
+ /** Where a bug happens, briefly: its spot, or the culprit's frame in the
84
+ * newest occurrence when the culprit names code this store does not hold. */ export let where = (e, newest)=>{
85
+ let bug = comp(e, 'bug');
86
+ if (bug.spot) {
87
+ let s = spot(str(bug.spot));
88
+ return [
89
+ s.place,
90
+ s.fn
91
+ ].filter(Boolean).join(' · ');
92
+ }
93
+ let frames = comp(newest, 'exception').frames ?? [];
94
+ let f = frames.find((f)=>f.symbol && f.symbol == bug.culprit) ?? frames.find((f)=>f.app) ?? frames[0];
95
+ return f ? frameAt(f) : '';
96
+ };
97
+ /** A frame's place and line, and what ran there. */ export let frameAt = (f)=>[
98
+ place(f.file) + (f.line ? `:${f.line}` : ''),
99
+ f.function
100
+ ].filter(Boolean).join(' · ');
101
+ /** Request identity is an exact association. Other context is a bounded time
102
+ * neighbour, not evidence that a trace contains or caused this error. */ export let relatedTraces = (e)=>{
103
+ let during = comp(e, 'during'), at = Date.parse(str(comp(e, 'error').at));
104
+ let quote = (v)=>JSON.stringify(str(v));
105
+ if (during.request) {
106
+ return {
107
+ query: `.trace .during.request=${quote(during.request)} * .order=-trace.at`,
108
+ label: 'Traces of the same request'
109
+ };
110
+ }
111
+ let key = during.entity ? 'entity' : during.process ? 'process' : undefined;
112
+ if (!key || !Number.isFinite(at)) return;
113
+ let scopes = [
114
+ 'space',
115
+ 'app'
116
+ ].filter((k)=>during[k]).map((k)=>`.during.${k}=${quote(during[k])}`).join(' ');
117
+ return {
118
+ query: `.trace .during.${key}=${quote(during[key])} ${scopes} .trace.at>=${quote(new Date(at - 300_000).toISOString())} .trace.at<=${quote(new Date(at + 300_000).toISOString())} * .order=-trace.at`,
119
+ label: `Traces within 5 minutes in the same ${key == 'entity' ? 'store or context' : 'process'}, nearby rather than causal`
120
+ };
121
+ };
122
+ //# sourceMappingURL=reading.js.map
package/reading.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reading.js","sources":["./reading.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wEAAwE;AAExE,SAAS,UAAU,oCAAyC;AAC5D,SAEE,GAAG,EAEH,EAAE,EACF,KAAK,EACL,IAAI,EACJ,KAAK,EACL,WAAW,2BACkB;AAC/B,SAAS,IAAI,EAAc,GAAG,EAAE,KAAK,qBAAoB;AACzD,SAAS,KAAK,EAAE,GAAG,EAAE,IAAI,qBAAoB;AAE7C,8EAA8E,GAC9E,OAAO,IAAI,WAAkB,IAAI,CAAC,mCAAmC,CAAC,CAAA;AACtE,+EAA+E,GAC/E,OAAO,IAAI,cAAc,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vE,IAAI,QAAQ,CAAC,IAAe,KAAK,SAAS,CAAC,IAAI;EAC/C,IAAI,OAAO,OAAO,EAAE;IAClB,OAAO;MACL,OAAO,CAAC,uBAAuB,EAC7B,MAAM,OAAO,OAAO,EACrB,mBAAmB,CAAC;MACrB,OAAO;IACT;EACF;EACA,IAAI,MAAM,OAAO,MAAM,GAAG,WAAW,OAAO,OAAO,GAAG,YAAY;EAClE,IAAI,CAAC,OAAO,CAAC,OAAO,QAAQ,CAAC,KAAK;EAClC,IAAI,SAAS;IAAC;IAAS;GAAM,CAAC,MAAM,CAAC,CAAC,IAAM,MAAM,CAAC,EAAE,EAClD,GAAG,CAAC,CAAC,IAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,MAAM,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC;EACvD,OAAO;IACL,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,YAAY,EACvE,MAAM,IAAI,KAAK,KAAK,SAAS,WAAW,IACzC,YAAY,EACX,MAAM,IAAI,KAAK,KAAK,SAAS,WAAW,IACzC,mBAAmB,CAAC;IACrB,OAAO,CAAC,oCAAoC,EAC1C,OAAO,WAAW,qBAAqB,UACxC,2BAA2B,CAAC;EAC/B;AACF,EAAC"}
package/reading.ts ADDED
@@ -0,0 +1,162 @@
1
+ // How a bug and an error read, whatever draws them: the whole message, where
2
+ // it happened, whether it is still broken, and the queries a page asks.
3
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
4
+ import { derivedEid } from '@yaks/graph/identity'
5
+ import {
6
+ type And,
7
+ and,
8
+ type Built,
9
+ eq,
10
+ every,
11
+ line,
12
+ order,
13
+ querySearch,
14
+ } from '@yaks/query'
15
+ import { comp, type Frame, str, title } from './model.js'
16
+ import { place, sha, spot } from './brief.js'
17
+
18
+ /** Worst first is historical occurrence count, not the retained sample size. */
19
+ export let openBugs: Built = line`.bug.status=open * .order=-bug.hits`
20
+ /** A bug's retained occurrences, newest first, as the query line a page asks. */
21
+ export let occurrences = (eid: string): Built =>
22
+ line`.error.bug=${eid} * .order=-error.at`
23
+ /** The same occurrences as a tree, for a read that need not parse a line that
24
+ * changes with every bug.
25
+ *
26
+ * ```ts
27
+ * import { equal } from '@yaks/testing'
28
+ * import { parse } from '@yaks/query'
29
+ * equal(occurring('b'), parse(occurrences('b')))
30
+ * ```
31
+ */
32
+ export let occurring = (eid: string): And =>
33
+ and(eq('error.bug', eid), every(), order('-error.at'))
34
+
35
+ /** The platform tracker's global eid: the scope a read names by default. */
36
+ export let platform: string = derivedEid('tracker|platform')
37
+
38
+ /** A bug's page on the box's tracker web when it lives on another side (the
39
+ * platform tracker, `yaks.app`), read through by global eid. A space's
40
+ * tracker holds its own bugs, so its page names that tracker's `scope`; one
41
+ * of the bug's occurrences opens on the same page.
42
+ *
43
+ * ```ts
44
+ * import { assertEquals } from '@std/assert'
45
+ * assertEquals(
46
+ * remoteBug('yaks.app', 'b', { error: 'e' }),
47
+ * '/?.bug&side=yaks.app&bug=b&error=e',
48
+ * )
49
+ * assertEquals(
50
+ * remoteBug('yaks.app', 'b', { scope: 's' }),
51
+ * '/?.bug&side=yaks.app&scope=s&bug=b',
52
+ * )
53
+ * assertEquals(
54
+ * remoteBug('yaks.app', 'b', { scope: platform }),
55
+ * '/?.bug&side=yaks.app&bug=b',
56
+ * )
57
+ * ```
58
+ */
59
+ export let remoteBug = (
60
+ side: string,
61
+ bug: string,
62
+ { scope, error }: { scope?: string; error?: string } = {},
63
+ ): string =>
64
+ `/${
65
+ querySearch('.bug', {
66
+ side,
67
+ ...scope && scope != platform ? { scope } : {},
68
+ bug,
69
+ ...error ? { error } : {},
70
+ })
71
+ }`
72
+
73
+ /** The whole message a bug or an error says. */
74
+ export let said = (e: Bundle): string =>
75
+ e.bug ? str(comp(e, 'doc').title) : title(e)
76
+
77
+ /// let bug = { entity: { eid: 'b' }, bug: {}, doc: { title: 'Error: first' } }
78
+ /// let back = (regressed: object) => ({ ...bug, regressed })
79
+ /// reopened(back({ message: 'Error: again\n at f', commit: 'a'.repeat(40) })) -> 'Error: again (aaaaaaa)'
80
+ /// reopened(back({ message: 'Error: red (aaaaaaa1b) https://ci/1', commit: 'a'.repeat(7) + '1b' + 'c'.repeat(31) })) -> 'Error: red (aaaaaaa1b) https://ci/1'
81
+ /// reopened(back({ message: 'Error: busy', commit: 'dafb20d7-a68f-4f8c-8393-9c038d0f854c' })) -> 'Error: busy (version dafb20d7)'
82
+ /// reopened(back({})) -> 'Error: first'
83
+ /** The hit that reopened a bug, in a line: its message and the code it ran
84
+ * on. A bug reopened before its mark said so reads as its title. */
85
+ export let reopened = (bug: Bundle): string => {
86
+ let back = comp(bug, 'regressed')
87
+ let line = (str(back.message) || said(bug)).split('\n')[0]
88
+ let code = ran(str(back.commit))
89
+ return code && !line.includes(code) ? `${line} (${code})` : line
90
+ }
91
+
92
+ /** The code a hit ran on, as people say it. A Worker reports its deployment's
93
+ * version, a UUID: said whole beside a bug, it reads as the bug's own id. */
94
+ let ran = (commit: string): string =>
95
+ /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(commit)
96
+ ? `version ${commit.slice(0, 8)}`
97
+ : sha(commit)
98
+
99
+ /** Where a bug is open, resolved or archived; regressed is open again. */
100
+ export let standing = (e: Bundle): string =>
101
+ str(comp(e, 'bug').status) ||
102
+ (e.archived ? 'archived' : e.resolved ? 'resolved' : 'open')
103
+
104
+ /** The dot a bug's standing wears: what is broken is a negative disc. */
105
+ export let pip = (e: Bundle): string[] =>
106
+ ({
107
+ open: e.regressed ? ['alert', 'negative'] : ['negative'],
108
+ resolved: ['check', 'positive'],
109
+ archived: ['ring'],
110
+ })[standing(e)] ?? ['ring']
111
+
112
+ /** Where a bug happens, briefly: its spot, or the culprit's frame in the
113
+ * newest occurrence when the culprit names code this store does not hold. */
114
+ export let where = (e: Bundle, newest?: Bundle): string => {
115
+ let bug = comp(e, 'bug')
116
+ if (bug.spot) {
117
+ let s = spot(str(bug.spot))
118
+ return [s.place, s.fn].filter(Boolean).join(' · ')
119
+ }
120
+ let frames = (comp(newest, 'exception').frames ?? []) as Frame[]
121
+ let f = frames.find((f) => f.symbol && f.symbol == bug.culprit) ??
122
+ frames.find((f) => f.app) ?? frames[0]
123
+ return f ? frameAt(f) : ''
124
+ }
125
+
126
+ /** A frame's place and line, and what ran there. */
127
+ export let frameAt = (f: Frame): string =>
128
+ [
129
+ place(f.file) + (f.line ? `:${f.line}` : ''),
130
+ f.function,
131
+ ].filter(Boolean).join(' · ')
132
+
133
+ /** Request identity is an exact association. Other context is a bounded time
134
+ * neighbour, not evidence that a trace contains or caused this error. */
135
+ export let relatedTraces = (
136
+ e: Bundle,
137
+ ): { query: string; label: string } | undefined => {
138
+ let during = comp(e, 'during'), at = Date.parse(str(comp(e, 'error').at))
139
+ let quote = (v: unknown) => JSON.stringify(str(v))
140
+ if (during.request) {
141
+ return {
142
+ query: `.trace .during.request=${
143
+ quote(during.request)
144
+ } * .order=-trace.at`,
145
+ label: 'Traces of the same request',
146
+ }
147
+ }
148
+ let key = during.entity ? 'entity' : during.process ? 'process' : undefined
149
+ if (!key || !Number.isFinite(at)) return
150
+ let scopes = ['space', 'app'].filter((k) => during[k])
151
+ .map((k) => `.during.${k}=${quote(during[k])}`).join(' ')
152
+ return {
153
+ query: `.trace .during.${key}=${quote(during[key])} ${scopes} .trace.at>=${
154
+ quote(new Date(at - 300_000).toISOString())
155
+ } .trace.at<=${
156
+ quote(new Date(at + 300_000).toISOString())
157
+ } * .order=-trace.at`,
158
+ label: `Traces within 5 minutes in the same ${
159
+ key == 'entity' ? 'store or context' : 'process'
160
+ }, nearby rather than causal`,
161
+ }
162
+ }
package/reconcile.js ADDED
@@ -0,0 +1,113 @@
1
+ // The Worker owns bug standing; the box owns its grouped evidence. Reconcile
2
+ // only marks on existing groups, never remote occurrences, counters or ids.
3
+ import { same } from "@yaks/fp";
4
+ import { Stale } from "@yaks/graph/errors";
5
+ import { token } from "@yaks/graph/sha256";
6
+ import { absent, and, eq, every, limit, or, order, present } from "@yaks/query";
7
+ import { comp, str } from "./model.js";
8
+ import { pages, signed, since } from "./poll.js";
9
+ let marks = [
10
+ 'resolved',
11
+ 'archived',
12
+ 'taken',
13
+ 'regressed'
14
+ ];
15
+ let app = (row)=>str(comp(row, 'bug').app ?? comp(row, 'during').app);
16
+ /** Global ids survive transport; older migrated groups instead share fault
17
+ * and app. A missing fault is not a grouping key. */ export let matches = (local, remote)=>!!local.bug && !!remote.bug && (local.entity.eid == remote.entity.eid || !!comp(remote, 'bug').fault && comp(local, 'bug').fault == comp(remote, 'bug').fault && app(local) == app(remote));
18
+ // Box and Worker each group a reopening and stamp it on their own clock. One
19
+ // the box grouped and has not seen resolved since is the reopening the
20
+ // Worker's mark names too, so its stamp stays: a moved `regressed.at` would be
21
+ // a second opening to its letters and its fixer's start.
22
+ let reopening = (local, remote)=>!!local.regressed && !!remote.regressed && (!local.resolved || !!remote.resolved);
23
+ /** A guarded, minimal standing patch, with removed explanation properties
24
+ * explicitly cleared. New local evidence must not be closed by an older
25
+ * remote snapshot, nor lose the regression that evidence just established. */ export let standing = (local, remote)=>{
26
+ if (!matches(local, remote)) return;
27
+ let newer = str(comp(local, 'bug').last) > str(comp(remote, 'bug').last);
28
+ let one = reopening(local, remote);
29
+ let patch = {
30
+ entity: {
31
+ eid: local.entity.eid
32
+ },
33
+ $was: {
34
+ bug: {
35
+ last: token(comp(local, 'bug').last)
36
+ },
37
+ resolved: {
38
+ at: token(comp(local, 'resolved').at)
39
+ }
40
+ }
41
+ };
42
+ let changed = false;
43
+ for (let name of marks){
44
+ if (name == 'regressed' && (newer || one) || newer && name == 'resolved' && remote.resolved) continue;
45
+ let before = local[name];
46
+ let after = remote[name];
47
+ if (same(before ?? null, after ?? null)) continue;
48
+ changed = true;
49
+ patch[name] = after ? {
50
+ ...Object.fromEntries(Object.keys(before ?? {}).map((k)=>[
51
+ k,
52
+ null
53
+ ])),
54
+ ...after
55
+ } : null;
56
+ patch.$was[name] = Object.fromEntries([
57
+ ...new Set([
58
+ 'at',
59
+ ...Object.keys(before ?? {}),
60
+ ...Object.keys(after ?? {})
61
+ ])
62
+ ].map((key)=>[
63
+ key,
64
+ token(before?.[key])
65
+ ]));
66
+ }
67
+ return changed ? patch : undefined;
68
+ };
69
+ /** One pass over the remote bugs (open and closed groups alike) that moved
70
+ * since the last, through the poll's signed reads (./poll.ts `since`). A pass
71
+ * that applied everything it read keeps the tag the remote stood at in
72
+ * `seen`, and the next pass sends it: a remote where nothing moved since says
73
+ * so with no row read, and one where something did names what moved, and
74
+ * only those are read. The first pass, or one whose tag the remote no longer
75
+ * knows what moved since, reads every bug. A raced local group is left for
76
+ * the next pass, which asks again from the tag before it. A read refused
77
+ * fails as the poll's does (./poll.ts `pages`), and the service decides what
78
+ * the failure is (./outage.ts). */ export let reconcile = async (g, remote, go = fetch, signal, seen = {})=>{
79
+ let page = pages(signed(remote, go), signal);
80
+ let fresh = await since(page, '.bug *', seen.tag);
81
+ if (!fresh) return;
82
+ let raced = false;
83
+ for (let row of fresh.rows){
84
+ signal?.throwIfAborted();
85
+ let [local] = await g.get([
86
+ row.entity.eid
87
+ ]);
88
+ if (!local?.bug) {
89
+ let fault = str(comp(row, 'bug').fault);
90
+ if (!fault) continue;
91
+ let scope = app(row);
92
+ let candidates = await g.read(and(present('bug'), eq('bug.fault', fault), scope ? or(eq('bug.app', scope), and(absent('bug.app'), eq('during.app', scope))) : and(absent('bug.app'), absent('during.app')), every(), order('entity.eid'), limit(2)));
93
+ // Ambiguous historical groups are not evidence that either is this bug.
94
+ if (candidates.length != 1) continue;
95
+ local = candidates[0];
96
+ }
97
+ let patch = standing(local, row);
98
+ if (!patch) continue;
99
+ try {
100
+ await g.apply([
101
+ patch
102
+ ], {
103
+ trusted: true,
104
+ stamp: false
105
+ });
106
+ } catch (error) {
107
+ if (!(error instanceof Stale)) throw error;
108
+ raced = true;
109
+ }
110
+ }
111
+ if (!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,GAAG;EAChD,IAAI,CAAC,OAAO;EACZ,IAAI,QAAQ;EACZ,KAAK,IAAI,OAAO,MAAM,IAAI,CAAE;IAC1B,QAAQ;IACR,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC;MAAC,IAAI,MAAM,CAAC,GAAG;KAAC;IAC1C,IAAI,CAAC,OAAO,KAAK;MACf,IAAI,QAAQ,IAAI,KAAK,KAAK,OAAO,KAAK;MACtC,IAAI,CAAC,OAAO;MACZ,IAAI,QAAQ,IAAI;MAChB,IAAI,aAAa,MAAM,EAAE,IAAI,CAAC,IAC5B,QAAQ,QACR,GAAG,aAAa,QAChB,QACI,GACA,GAAG,WAAW,QACd,IAAI,OAAO,YAAY,GAAG,cAAc,WAExC,IAAI,OAAO,YAAY,OAAO,gBAClC,SACA,MAAM,eACN,MAAM;MAER,wEAAwE;MACxE,IAAI,WAAW,MAAM,IAAI,GAAG;MAC5B,QAAQ,UAAU,CAAC,EAAE;IACvB;IACA,IAAI,QAAQ,SAAS,OAAO;IAC5B,IAAI,CAAC,OAAO;IACZ,IAAI;MACF,MAAM,EAAE,KAAK,CAAC;QAAC;OAAM,EAAE;QAAE,SAAS;QAAM,OAAO;MAAM;IACvD,EAAE,OAAO,OAAO;MACd,IAAI,CAAC,CAAC,iBAAiB,KAAK,GAAG,MAAM;MACrC,QAAQ;IACV;EACF;EACA,IAAI,CAAC,OAAO,KAAK,GAAG,GAAG,MAAM,GAAG;AAClC,EAAC"}
package/reconcile.ts ADDED
@@ -0,0 +1,130 @@
1
+ // The Worker owns bug standing; the box owns its grouped evidence. Reconcile
2
+ // only marks on existing groups, never remote occurrences, counters or ids.
3
+ import { same } from '@yaks/fp'
4
+ import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
5
+ import { Stale } from '@yaks/graph/errors'
6
+ import { token } from '@yaks/graph/sha256'
7
+ import { absent, and, eq, every, limit, or, order, present } from '@yaks/query'
8
+ import { comp, type Desk, str } from './model.js'
9
+ import type { Remote } from './remote.ts'
10
+ import { pages, signed, since } from './poll.js'
11
+
12
+ let marks = ['resolved', 'archived', 'taken', 'regressed'] as const
13
+ let app = (row: Bundle) => str(comp(row, 'bug').app ?? comp(row, 'during').app)
14
+
15
+ /** Global ids survive transport; older migrated groups instead share fault
16
+ * and app. A missing fault is not a grouping key. */
17
+ export let matches = (local: Bundle, remote: Bundle): boolean =>
18
+ !!local.bug && !!remote.bug && (local.entity.eid == remote.entity.eid ||
19
+ !!comp(remote, 'bug').fault &&
20
+ comp(local, 'bug').fault == comp(remote, 'bug').fault &&
21
+ app(local) == app(remote))
22
+
23
+ // Box and Worker each group a reopening and stamp it on their own clock. One
24
+ // the box grouped and has not seen resolved since is the reopening the
25
+ // Worker's mark names too, so its stamp stays: a moved `regressed.at` would be
26
+ // a second opening to its letters and its fixer's start.
27
+ let reopening = (local: Bundle, remote: Bundle) =>
28
+ !!local.regressed && !!remote.regressed &&
29
+ (!local.resolved || !!remote.resolved)
30
+
31
+ /** A guarded, minimal standing patch, with removed explanation properties
32
+ * explicitly cleared. New local evidence must not be closed by an older
33
+ * remote snapshot, nor lose the regression that evidence just established. */
34
+ export let standing = (local: Bundle, remote: Bundle): Bundle | undefined => {
35
+ if (!matches(local, remote)) return
36
+ let newer = str(comp(local, 'bug').last) > str(comp(remote, 'bug').last)
37
+ let one = reopening(local, remote)
38
+ let patch: Bundle = {
39
+ entity: { eid: local.entity.eid },
40
+ $was: {
41
+ bug: { last: token(comp(local, 'bug').last) },
42
+ resolved: { at: token(comp(local, 'resolved').at) },
43
+ },
44
+ }
45
+ let changed = false
46
+ for (let name of marks) {
47
+ if (
48
+ name == 'regressed' && (newer || one) ||
49
+ newer && name == 'resolved' && remote.resolved
50
+ ) continue
51
+ let before = local[name] as Comp | undefined
52
+ let after = remote[name] as Comp | undefined
53
+ if (same(before ?? null, after ?? null)) continue
54
+ changed = true
55
+ patch[name] = after
56
+ ? {
57
+ ...Object.fromEntries(Object.keys(before ?? {}).map((k) => [k, null])),
58
+ ...after,
59
+ }
60
+ : null
61
+ patch.$was![name] = Object.fromEntries(
62
+ [
63
+ ...new Set([
64
+ 'at',
65
+ ...Object.keys(before ?? {}),
66
+ ...Object.keys(after ?? {}),
67
+ ]),
68
+ ]
69
+ .map((key) => [key, token(before?.[key])]),
70
+ )
71
+ }
72
+ return changed ? patch : undefined
73
+ }
74
+
75
+ /** One pass over the remote bugs (open and closed groups alike) that moved
76
+ * since the last, through the poll's signed reads (./poll.ts `since`). A pass
77
+ * that applied everything it read keeps the tag the remote stood at in
78
+ * `seen`, and the next pass sends it: a remote where nothing moved since says
79
+ * so with no row read, and one where something did names what moved, and
80
+ * only those are read. The first pass, or one whose tag the remote no longer
81
+ * knows what moved since, reads every bug. A raced local group is left for
82
+ * the next pass, which asks again from the tag before it. A read refused
83
+ * fails as the poll's does (./poll.ts `pages`), and the service decides what
84
+ * the failure is (./outage.ts). */
85
+ export let reconcile = async (
86
+ g: Desk,
87
+ remote: Remote,
88
+ go: typeof fetch = fetch,
89
+ signal?: AbortSignal,
90
+ seen: { tag?: string } = {},
91
+ ): Promise<void> => {
92
+ let page = pages(signed(remote, go), signal)
93
+ let fresh = await since(page, '.bug *', seen.tag)
94
+ if (!fresh) return
95
+ let raced = false
96
+ for (let row of fresh.rows) {
97
+ signal?.throwIfAborted()
98
+ let [local] = await g.get([row.entity.eid])
99
+ if (!local?.bug) {
100
+ let fault = str(comp(row, 'bug').fault)
101
+ if (!fault) continue
102
+ let scope = app(row)
103
+ let candidates = await g.read(and(
104
+ present('bug'),
105
+ eq('bug.fault', fault),
106
+ scope
107
+ ? or(
108
+ eq('bug.app', scope),
109
+ and(absent('bug.app'), eq('during.app', scope)),
110
+ )
111
+ : and(absent('bug.app'), absent('during.app')),
112
+ every(),
113
+ order('entity.eid'),
114
+ limit(2),
115
+ ))
116
+ // Ambiguous historical groups are not evidence that either is this bug.
117
+ if (candidates.length != 1) continue
118
+ local = candidates[0]
119
+ }
120
+ let patch = standing(local, row)
121
+ if (!patch) continue
122
+ try {
123
+ await g.apply([patch], { trusted: true, stamp: false })
124
+ } catch (error) {
125
+ if (!(error instanceof Stale)) throw error
126
+ raced = true
127
+ }
128
+ }
129
+ if (!raced) seen.tag = fresh.tag
130
+ }