@chatwarden/core 0.1.6 → 0.1.8

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 (196) hide show
  1. package/README.md +173 -3
  2. package/dist/src/ai/agreement.d.ts +46 -0
  3. package/dist/src/ai/agreement.d.ts.map +1 -0
  4. package/dist/src/ai/agreement.js +71 -0
  5. package/dist/src/ai/agreement.js.map +1 -0
  6. package/dist/src/ai/breaker.d.ts +31 -0
  7. package/dist/src/ai/breaker.d.ts.map +1 -0
  8. package/dist/src/ai/breaker.js +62 -0
  9. package/dist/src/ai/breaker.js.map +1 -0
  10. package/dist/src/ai/budget.d.ts +26 -0
  11. package/dist/src/ai/budget.d.ts.map +1 -0
  12. package/dist/src/ai/budget.js +57 -0
  13. package/dist/src/ai/budget.js.map +1 -0
  14. package/dist/src/ai/case.d.ts +37 -0
  15. package/dist/src/ai/case.d.ts.map +1 -0
  16. package/dist/src/ai/case.js +30 -0
  17. package/dist/src/ai/case.js.map +1 -0
  18. package/dist/src/ai/casebook.d.ts +59 -0
  19. package/dist/src/ai/casebook.d.ts.map +1 -0
  20. package/dist/src/ai/casebook.js +47 -0
  21. package/dist/src/ai/casebook.js.map +1 -0
  22. package/dist/src/ai/ceilings.d.ts +42 -0
  23. package/dist/src/ai/ceilings.d.ts.map +1 -0
  24. package/dist/src/ai/ceilings.js +59 -0
  25. package/dist/src/ai/ceilings.js.map +1 -0
  26. package/dist/src/ai/fake.d.ts +41 -0
  27. package/dist/src/ai/fake.d.ts.map +1 -0
  28. package/dist/src/ai/fake.js +75 -0
  29. package/dist/src/ai/fake.js.map +1 -0
  30. package/dist/src/ai/hash.d.ts +15 -0
  31. package/dist/src/ai/hash.d.ts.map +1 -0
  32. package/dist/src/ai/hash.js +22 -0
  33. package/dist/src/ai/hash.js.map +1 -0
  34. package/dist/src/ai/inert.d.ts +5 -0
  35. package/dist/src/ai/inert.d.ts.map +1 -0
  36. package/dist/src/ai/inert.js +22 -0
  37. package/dist/src/ai/inert.js.map +1 -0
  38. package/dist/src/ai/injection.d.ts +8 -0
  39. package/dist/src/ai/injection.d.ts.map +1 -0
  40. package/dist/src/ai/injection.js +30 -0
  41. package/dist/src/ai/injection.js.map +1 -0
  42. package/dist/src/ai/lines.d.ts +64 -0
  43. package/dist/src/ai/lines.d.ts.map +1 -0
  44. package/dist/src/ai/lines.js +172 -0
  45. package/dist/src/ai/lines.js.map +1 -0
  46. package/dist/src/ai/prompt.d.ts +48 -0
  47. package/dist/src/ai/prompt.d.ts.map +1 -0
  48. package/dist/src/ai/prompt.js +196 -0
  49. package/dist/src/ai/prompt.js.map +1 -0
  50. package/dist/src/ai/redact.d.ts +29 -0
  51. package/dist/src/ai/redact.d.ts.map +1 -0
  52. package/dist/src/ai/redact.js +160 -0
  53. package/dist/src/ai/redact.js.map +1 -0
  54. package/dist/src/ai/schema.d.ts +6 -0
  55. package/dist/src/ai/schema.d.ts.map +1 -0
  56. package/dist/src/ai/schema.js +50 -0
  57. package/dist/src/ai/schema.js.map +1 -0
  58. package/dist/src/ai/service.d.ts +332 -0
  59. package/dist/src/ai/service.d.ts.map +1 -0
  60. package/dist/src/ai/service.js +751 -0
  61. package/dist/src/ai/service.js.map +1 -0
  62. package/dist/src/ai/types.d.ts +196 -0
  63. package/dist/src/ai/types.d.ts.map +1 -0
  64. package/dist/src/ai/types.js +23 -0
  65. package/dist/src/ai/types.js.map +1 -0
  66. package/dist/src/ai/validate.d.ts +30 -0
  67. package/dist/src/ai/validate.d.ts.map +1 -0
  68. package/dist/src/ai/validate.js +160 -0
  69. package/dist/src/ai/validate.js.map +1 -0
  70. package/dist/src/ai/worker.d.ts +76 -0
  71. package/dist/src/ai/worker.d.ts.map +1 -0
  72. package/dist/src/ai/worker.js +293 -0
  73. package/dist/src/ai/worker.js.map +1 -0
  74. package/dist/src/audit.d.ts +12 -3
  75. package/dist/src/audit.d.ts.map +1 -1
  76. package/dist/src/audit.js +30 -4
  77. package/dist/src/audit.js.map +1 -1
  78. package/dist/src/chat.d.ts +39 -1
  79. package/dist/src/chat.d.ts.map +1 -1
  80. package/dist/src/chat.js +85 -6
  81. package/dist/src/chat.js.map +1 -1
  82. package/dist/src/chatwarden.d.ts +84 -1
  83. package/dist/src/chatwarden.d.ts.map +1 -1
  84. package/dist/src/chatwarden.js +168 -6
  85. package/dist/src/chatwarden.js.map +1 -1
  86. package/dist/src/decide.d.ts +36 -1
  87. package/dist/src/decide.d.ts.map +1 -1
  88. package/dist/src/decide.js +62 -2
  89. package/dist/src/decide.js.map +1 -1
  90. package/dist/src/documents.d.ts +1 -1
  91. package/dist/src/documents.d.ts.map +1 -1
  92. package/dist/src/documents.js +6 -1
  93. package/dist/src/documents.js.map +1 -1
  94. package/dist/src/freeze.d.ts +3 -0
  95. package/dist/src/freeze.d.ts.map +1 -0
  96. package/dist/src/freeze.js +10 -0
  97. package/dist/src/freeze.js.map +1 -0
  98. package/dist/src/index.d.ts +37 -8
  99. package/dist/src/index.d.ts.map +1 -1
  100. package/dist/src/index.js +23 -3
  101. package/dist/src/index.js.map +1 -1
  102. package/dist/src/ladder.d.ts +28 -0
  103. package/dist/src/ladder.d.ts.map +1 -1
  104. package/dist/src/ladder.js +37 -1
  105. package/dist/src/ladder.js.map +1 -1
  106. package/dist/src/pace.d.ts +66 -0
  107. package/dist/src/pace.d.ts.map +1 -0
  108. package/dist/src/pace.js +111 -0
  109. package/dist/src/pace.js.map +1 -0
  110. package/dist/src/pacing.d.ts +63 -0
  111. package/dist/src/pacing.d.ts.map +1 -0
  112. package/dist/src/pacing.js +198 -0
  113. package/dist/src/pacing.js.map +1 -0
  114. package/dist/src/policy.d.ts +57 -1
  115. package/dist/src/policy.d.ts.map +1 -1
  116. package/dist/src/policy.js +67 -4
  117. package/dist/src/policy.js.map +1 -1
  118. package/dist/src/profile.d.ts +64 -8
  119. package/dist/src/profile.d.ts.map +1 -1
  120. package/dist/src/profile.js +98 -27
  121. package/dist/src/profile.js.map +1 -1
  122. package/dist/src/profileError.d.ts +10 -0
  123. package/dist/src/profileError.d.ts.map +1 -0
  124. package/dist/src/profileError.js +17 -0
  125. package/dist/src/profileError.js.map +1 -0
  126. package/dist/src/retention.d.ts +28 -0
  127. package/dist/src/retention.d.ts.map +1 -1
  128. package/dist/src/retention.js +42 -10
  129. package/dist/src/retention.js.map +1 -1
  130. package/dist/src/signalCounts.d.ts +37 -0
  131. package/dist/src/signalCounts.d.ts.map +1 -0
  132. package/dist/src/signalCounts.js +117 -0
  133. package/dist/src/signalCounts.js.map +1 -0
  134. package/dist/src/signalInert.d.ts +10 -0
  135. package/dist/src/signalInert.d.ts.map +1 -0
  136. package/dist/src/signalInert.js +28 -0
  137. package/dist/src/signalInert.js.map +1 -0
  138. package/dist/src/signalService.d.ts +101 -0
  139. package/dist/src/signalService.d.ts.map +1 -0
  140. package/dist/src/signalService.js +383 -0
  141. package/dist/src/signalService.js.map +1 -0
  142. package/dist/src/signals.d.ts +186 -0
  143. package/dist/src/signals.d.ts.map +1 -0
  144. package/dist/src/signals.js +361 -0
  145. package/dist/src/signals.js.map +1 -0
  146. package/dist/src/subjects.d.ts +2 -0
  147. package/dist/src/subjects.d.ts.map +1 -1
  148. package/dist/src/subjects.js +4 -0
  149. package/dist/src/subjects.js.map +1 -1
  150. package/dist/src/team.d.ts +27 -0
  151. package/dist/src/team.d.ts.map +1 -1
  152. package/dist/src/team.js +92 -4
  153. package/dist/src/team.js.map +1 -1
  154. package/dist/src/types.d.ts +324 -2
  155. package/dist/src/types.d.ts.map +1 -1
  156. package/dist/src/types.js.map +1 -1
  157. package/package.json +2 -2
  158. package/src/ai/agreement.ts +106 -0
  159. package/src/ai/breaker.ts +73 -0
  160. package/src/ai/budget.ts +65 -0
  161. package/src/ai/case.ts +74 -0
  162. package/src/ai/casebook.ts +75 -0
  163. package/src/ai/ceilings.ts +68 -0
  164. package/src/ai/fake.ts +105 -0
  165. package/src/ai/hash.ts +23 -0
  166. package/src/ai/inert.ts +26 -0
  167. package/src/ai/injection.ts +32 -0
  168. package/src/ai/lines.ts +216 -0
  169. package/src/ai/prompt.ts +223 -0
  170. package/src/ai/redact.ts +174 -0
  171. package/src/ai/schema.ts +51 -0
  172. package/src/ai/service.ts +961 -0
  173. package/src/ai/types.ts +182 -0
  174. package/src/ai/validate.ts +173 -0
  175. package/src/ai/worker.ts +372 -0
  176. package/src/audit.ts +31 -5
  177. package/src/chat.ts +109 -8
  178. package/src/chatwarden.ts +248 -8
  179. package/src/decide.ts +97 -4
  180. package/src/documents.ts +7 -2
  181. package/src/freeze.ts +8 -0
  182. package/src/index.ts +91 -2
  183. package/src/ladder.ts +59 -1
  184. package/src/pace.ts +139 -0
  185. package/src/pacing.ts +242 -0
  186. package/src/policy.ts +107 -7
  187. package/src/profile.ts +149 -27
  188. package/src/profileError.ts +17 -0
  189. package/src/retention.ts +63 -10
  190. package/src/signalCounts.ts +133 -0
  191. package/src/signalInert.ts +31 -0
  192. package/src/signalService.ts +406 -0
  193. package/src/signals.ts +489 -0
  194. package/src/subjects.ts +5 -0
  195. package/src/team.ts +93 -5
  196. package/src/types.ts +358 -2
@@ -0,0 +1,186 @@
1
+ import type { RawWho, SubjectId } from './types.js';
2
+ export type SignalPolarity = 'negative' | 'positive';
3
+ /**
4
+ * One kind a game declares. The key in `kinds` is the id the game passes to `record`.
5
+ * @experimental
6
+ */
7
+ export interface SignalKindSpec {
8
+ /** What staff read: "Muted by other players". Plain text, 1 to 60 characters, no markup. Also the label the AI feed sends. */
9
+ label: string;
10
+ polarity: SignalPolarity;
11
+ /** Default weight of one source, 0 to 10, default 1. A record may override it per call. */
12
+ weight?: number;
13
+ }
14
+ /** @experimental */
15
+ export interface SignalGuards {
16
+ /**
17
+ * At most one row per (kind, subject, source) per this many ms. Default 86 400 000 (one day). 60 000 to 30 days. The cap is a calendar bucket
18
+ * (`floor(at / perByWindowMs)`), not a rolling window: two rows a millisecond apart across a bucket edge both insert, and changing this later
19
+ * re-buckets the rows already stored.
20
+ */
21
+ perByWindowMs?: number;
22
+ /** Used ONLY when the adopter supplies `signals.accountAgeDays` to createChatwarden. Default: not set (no weighting). */
23
+ newAccount?: {
24
+ belowDays: number;
25
+ factor: number;
26
+ } | null;
27
+ }
28
+ /**
29
+ * One threshold, over distinct sources, in a window.
30
+ * @experimental
31
+ */
32
+ export interface SignalThreshold {
33
+ /** Declared kinds, 1 to 8. */
34
+ kinds: string[];
35
+ /** 1 to 50 distinct sources with weight above 0. */
36
+ minDistinct: number;
37
+ /** 1 to 90, and not above retention.signalsMs. */
38
+ windowDays: number;
39
+ /** The sum of those sources' weights must also reach this. */
40
+ minWeight?: number;
41
+ }
42
+ /**
43
+ * The feeds. Absent means that feed is off.
44
+ * @experimental
45
+ */
46
+ export interface SignalFeeds {
47
+ /** Lines on the Person page record. `'*'` means every declared kind. */
48
+ record?: {
49
+ kinds: string[] | '*';
50
+ windowDays: number;
51
+ };
52
+ /** Queue ordering: a person who meets the threshold ranks ahead of older ordinary cases, capped. Negative kinds only. */
53
+ queue?: SignalThreshold;
54
+ /** The ladder. `note` adds a sentence to the suggestion; `raise` moves it up one step. `raise` takes negative kinds only. */
55
+ ladder?: Array<SignalThreshold & {
56
+ id: string;
57
+ effect: 'note' | 'raise';
58
+ }>;
59
+ /** The AI read's case context. */
60
+ ai?: {
61
+ kinds: string[] | '*';
62
+ windowDays: number;
63
+ };
64
+ }
65
+ /** @experimental */
66
+ export interface SignalSettings {
67
+ /** Code only. */
68
+ kinds?: Record<string, SignalKindSpec>;
69
+ /** Code only. */
70
+ guards?: SignalGuards;
71
+ /** Editable in the hub. */
72
+ feeds?: SignalFeeds;
73
+ }
74
+ /** The kind with every field filled in. */
75
+ export interface ResolvedSignalKind {
76
+ label: string;
77
+ polarity: SignalPolarity;
78
+ weight: number;
79
+ }
80
+ /** The guards with every field filled in; `newAccount` is null when not set. */
81
+ export interface ResolvedSignalGuards {
82
+ perByWindowMs: number;
83
+ newAccount: {
84
+ belowDays: number;
85
+ factor: number;
86
+ } | null;
87
+ }
88
+ /**
89
+ * What the kit reads: the declared kinds merged over the built-ins, the guards filled in, the feeds as given. Look kinds up with
90
+ * {@link kindSpecOf}, never with `kinds[id]`.
91
+ * @experimental
92
+ */
93
+ export interface ResolvedSignals {
94
+ kinds: Readonly<Record<string, ResolvedSignalKind>>;
95
+ guards: ResolvedSignalGuards;
96
+ feeds: SignalFeeds;
97
+ }
98
+ /** Who a signal is about or from: a staff-side subject id (`cw.rooms.subjectAt`), or the raw identity the game already passes to the doors. */
99
+ export type SignalParty = SubjectId | RawWho;
100
+ /** @experimental */
101
+ export interface SignalInput {
102
+ /** A declared kind (or a built-in). */
103
+ kind: string;
104
+ /** Whom it is about. */
105
+ subject: SignalParty;
106
+ /** Who produced it (the player who muted, the player who left). Omit (or `null`) for a source the game itself is, such as a timeout. */
107
+ by?: SignalParty | null;
108
+ /** The game's own room id: 1 to 64 characters of A-Z a-z 0-9 _ . : - . Not player text. `null` is the same as leaving it out. */
109
+ roomId?: string | null;
110
+ /** When it happened, epoch ms. Default: now (also for `null`). Not more than 5 minutes ahead, not older than retention.signalsMs. */
111
+ at?: number | null;
112
+ /** Overrides the kind's default weight for this one record. 0 to 10. */
113
+ weight?: number;
114
+ }
115
+ /** @experimental */
116
+ export interface SignalCount {
117
+ kind: string;
118
+ label: string;
119
+ polarity: SignalPolarity;
120
+ /** Distinct sources with weight above 0 in the window. */
121
+ distinct: number;
122
+ /** The sum of those sources' weights. */
123
+ weight: number;
124
+ windowDays: number;
125
+ firstAt: number;
126
+ lastAt: number;
127
+ }
128
+ /** @experimental */
129
+ export interface SignalKindView {
130
+ kind: string;
131
+ label: string;
132
+ polarity: SignalPolarity;
133
+ weight: number;
134
+ builtin: boolean;
135
+ }
136
+ /**
137
+ * Kinds the kit declares itself. An adopter may relabel or re-weight one by declaring the same key; the polarity must stay negative.
138
+ * @experimental
139
+ */
140
+ export declare const BUILTIN_SIGNAL_KINDS: Readonly<Record<'flood_triggered', Readonly<SignalKindSpec>>>;
141
+ /** A kind id: a lower-case slug. */
142
+ export declare const SIGNAL_KIND_PATTERN: RegExp;
143
+ /** The most kinds a game may declare. */
144
+ export declare const SIGNAL_KINDS_MAX = 40;
145
+ /** The longest window a feed may name, in days. */
146
+ export declare const SIGNAL_WINDOW_DAYS_MAX = 90;
147
+ /** The feeds, in the order a settings screen lists them. */
148
+ export declare const SIGNAL_FEED_NAMES: readonly string[];
149
+ /**
150
+ * The declared spec of a kind, from the kinds `resolveSignals` returned, or undefined. Reads own properties only, so `constructor`,
151
+ * `toString` and `__proto__` are never found unless a game declared them.
152
+ */
153
+ export declare function kindSpecOf(kinds: Readonly<Record<string, ResolvedSignalKind>>, id: string): ResolvedSignalKind | undefined;
154
+ /**
155
+ * Check the feeds against the declared `kinds` and `opts.signalsMs` (the retention of signal rows, ms), throwing {@link ProfileError}
156
+ * whose path starts with `path` (`path.queue.kinds[0]`). A feed names declared kinds only; `queue` and a `raise` rule name negative
157
+ * kinds only; a count and a window are in range; a window is not longer than `signalsMs` (rows older than that are gone) or 90 days.
158
+ * @experimental
159
+ */
160
+ export declare function checkSignalFeeds(feeds: SignalFeeds | undefined, kinds: Readonly<Record<string, ResolvedSignalKind>>, opts: {
161
+ signalsMs: number;
162
+ }, path: string): void;
163
+ /** Why a stored feed was dropped: a code, never a value. */
164
+ export type SignalDropReason = 'unknown_feed' | 'unknown_kind' | 'positive_kind' | 'window' | 'invalid';
165
+ /**
166
+ * The feeds minus anything that can no longer be used: a feed (or a ladder rule) naming a kind the code stopped declaring, a positive
167
+ * kind where only negative ones are allowed, a window longer than `opts.signalsMs` or 90 days, or any other shape the checks refuse.
168
+ * Applied to a STORED layer at start-up, so one stale feed is dropped on its own and the rest of the layer (the ladder edits too) stays
169
+ * in force. Never throws: garbage in gives `{}`. `opts.onDrop` is told the name of each feed that lost something, once per feed, with
170
+ * the reason code of the first thing lost (a name that is not one of the four feeds is passed as it was stored, with `unknown_feed`: do
171
+ * not log it). The result passes {@link checkSignalFeeds}.
172
+ * @experimental
173
+ */
174
+ export declare function pruneSignalFeeds(feeds: unknown, kinds: Readonly<Record<string, ResolvedSignalKind>>, opts: {
175
+ signalsMs: number;
176
+ onDrop?: (feed: string, reason: SignalDropReason) => void;
177
+ }): SignalFeeds;
178
+ /**
179
+ * Validate the `signals` section and fill it in: the declared kinds merged over the built-ins, the guards with their defaults, the
180
+ * feeds as given. Throws {@link ProfileError} naming the field (`signals.kinds.x.label`), never echoing the value. The feeds are
181
+ * checked against the declared kinds and the 90 day cap here; the cross-check with `retention.signalsMs` is {@link checkSignalFeeds}'s
182
+ * job, called where the retention is known. The result shares nothing with the input, and resolving it again gives the same value.
183
+ * @experimental
184
+ */
185
+ export declare function resolveSignals(input: SignalSettings | undefined, path?: string): ResolvedSignals;
186
+ //# sourceMappingURL=signals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWpD,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,8HAA8H;IAC9H,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;IACzB,2FAA2F;IAC3F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,oBAAoB;AACpB,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yHAAyH;IACzH,UAAU,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC3D;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAk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C5D,yCAAyC;AACzC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,mDAAmD;AACnD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAmBzC,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAwC,CAAC;AA6BxF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE1H;AAuJD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,EACnD,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC3B,IAAI,EAAE,MAAM,GACX,IAAI,CAaN;AAED,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;AAQxG;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,EACnD,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAA;CAAE,GACrF,WAAW,CAmDb;AASD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,EAAE,IAAI,SAAY,GAAG,eAAe,CASnG"}
@@ -0,0 +1,361 @@
1
+ import { deepFreeze } from './freeze.js';
2
+ import { ProfileError } from './profileError.js';
3
+ // Signals: what a game records about a player (muted by others, kicked, left mid-game), declared in code, counted by distinct source and
4
+ // read by three feeds only because a profile rule says so. A signal never acts. This file has the declarations and their validation
5
+ // (`kinds`, `guards`, `feeds`) and the shapes the rest of the feature shares; counting is signalCounts.ts, the store is types.ts.
6
+ //
7
+ // Kind ids are the adopter's strings, so every lookup here uses OWN properties only: `constructor` and `toString` never resolve from
8
+ // the prototype. Nothing a validator throws echoes a value.
9
+ const DAY_MS = 86_400_000;
10
+ /**
11
+ * Kinds the kit declares itself. An adopter may relabel or re-weight one by declaring the same key; the polarity must stay negative.
12
+ * @experimental
13
+ */
14
+ export const BUILTIN_SIGNAL_KINDS = deepFreeze({
15
+ flood_triggered: { label: 'Flooded the chat', polarity: 'negative' },
16
+ });
17
+ /** A kind id: a lower-case slug. */
18
+ export const SIGNAL_KIND_PATTERN = /^[a-z][a-z0-9_]{0,39}$/;
19
+ /** The most kinds a game may declare. */
20
+ export const SIGNAL_KINDS_MAX = 40;
21
+ /** The longest window a feed may name, in days. */
22
+ export const SIGNAL_WINDOW_DAYS_MAX = 90;
23
+ const LABEL_MAX = 60;
24
+ const WEIGHT_MAX = 10;
25
+ const THRESHOLD_KINDS_MAX = 8;
26
+ const MIN_DISTINCT_MAX = 50;
27
+ const MIN_WEIGHT_MAX = MIN_DISTINCT_MAX * WEIGHT_MAX;
28
+ const LADDER_RULES_MAX = 20;
29
+ const RULE_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,39}$/;
30
+ const PER_BY_MIN_MS = 60_000;
31
+ const PER_BY_MAX_MS = 30 * DAY_MS;
32
+ const PER_BY_DEFAULT_MS = DAY_MS;
33
+ const NEW_ACCOUNT_DAYS_MAX = 365;
34
+ const BUILTIN_IDS = Object.keys(BUILTIN_SIGNAL_KINDS);
35
+ const KIND_KEYS = ['label', 'polarity', 'weight'];
36
+ const GUARD_KEYS = ['perByWindowMs', 'newAccount'];
37
+ const NEW_ACCOUNT_KEYS = ['belowDays', 'factor'];
38
+ const SETTINGS_KEYS = ['kinds', 'guards', 'feeds'];
39
+ /** The feeds, in the order a settings screen lists them. */
40
+ export const SIGNAL_FEED_NAMES = ['record', 'queue', 'ladder', 'ai'];
41
+ const THRESHOLD_KEYS = ['kinds', 'minDistinct', 'windowDays', 'minWeight'];
42
+ const RULE_KEYS = ['id', 'effect', ...THRESHOLD_KEYS];
43
+ const WINDOW_FEED_KEYS = ['kinds', 'windowDays'];
44
+ function fail(path, reason, code) {
45
+ throw new ProfileError(path, reason, code);
46
+ }
47
+ function isPlain(v) {
48
+ if (typeof v !== 'object' || v === null || Array.isArray(v))
49
+ return false;
50
+ const proto = Object.getPrototypeOf(v);
51
+ return proto === Object.prototype || proto === null;
52
+ }
53
+ /** An own value, or undefined. A key left out and an inherited property both read as "not given". */
54
+ function given(o, key) {
55
+ return Object.hasOwn(o, key) ? o[key] : undefined;
56
+ }
57
+ function setOwn(target, key, value) {
58
+ // defineProperty, so a `__proto__` key becomes a plain own key.
59
+ Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
60
+ }
61
+ function onlyKeys(o, allowed, path) {
62
+ for (const k of Object.keys(o))
63
+ if (!allowed.includes(k))
64
+ fail(`${path}.${k}`, 'is not a known setting');
65
+ }
66
+ /**
67
+ * The declared spec of a kind, from the kinds `resolveSignals` returned, or undefined. Reads own properties only, so `constructor`,
68
+ * `toString` and `__proto__` are never found unless a game declared them.
69
+ */
70
+ export function kindSpecOf(kinds, id) {
71
+ return typeof id === 'string' && Object.hasOwn(kinds, id) ? kinds[id] : undefined;
72
+ }
73
+ // ---------------------------------------------------------------------------------------------------------------
74
+ // Kinds and guards
75
+ function whole(v, min, max) {
76
+ return typeof v === 'number' && Number.isSafeInteger(v) && v >= min && v <= max;
77
+ }
78
+ /** Plain text on one line: no angle brackets (markup) and no control characters. */
79
+ function plainLabel(v) {
80
+ return typeof v === 'string' && v.length >= 1 && v.length <= LABEL_MAX && v.trim() !== '' && !/[<>\p{C}\p{Zl}\p{Zp}]/u.test(v);
81
+ }
82
+ function kindSpec(id, v, path) {
83
+ if (!isPlain(v))
84
+ return fail(path, 'must be an object with a label and a polarity');
85
+ onlyKeys(v, KIND_KEYS, path);
86
+ const label = given(v, 'label');
87
+ if (!plainLabel(label))
88
+ fail(`${path}.label`, `must be plain text of 1 to ${LABEL_MAX} characters, on one line, with no markup`);
89
+ const polarity = given(v, 'polarity');
90
+ if (polarity !== 'negative' && polarity !== 'positive')
91
+ fail(`${path}.polarity`, "must be 'negative' or 'positive'");
92
+ if (BUILTIN_IDS.includes(id) && polarity !== 'negative')
93
+ fail(`${path}.polarity`, "must stay 'negative': the kit records this kind itself");
94
+ const weight = given(v, 'weight');
95
+ if (weight !== undefined && !(typeof weight === 'number' && Number.isFinite(weight) && weight >= 0 && weight <= WEIGHT_MAX)) {
96
+ fail(`${path}.weight`, `must be a number from 0 to ${WEIGHT_MAX}`);
97
+ }
98
+ return { label, polarity, weight: weight ?? 1 };
99
+ }
100
+ function resolveKinds(v, path) {
101
+ // No prototype, so a plain `kinds['constructor']` finds nothing unless a game declared it.
102
+ const out = Object.create(null);
103
+ for (const id of BUILTIN_IDS) {
104
+ const b = BUILTIN_SIGNAL_KINDS[id];
105
+ setOwn(out, id, { label: b.label, polarity: b.polarity, weight: 1 });
106
+ }
107
+ if (v === undefined)
108
+ return out;
109
+ if (!isPlain(v))
110
+ return fail(path, 'must be an object of kinds');
111
+ const ids = Object.keys(v);
112
+ if (ids.length > SIGNAL_KINDS_MAX)
113
+ fail(path, `must declare at most ${SIGNAL_KINDS_MAX} kinds`);
114
+ for (const id of ids) {
115
+ if (!SIGNAL_KIND_PATTERN.test(id))
116
+ fail(path, 'has a kind id that is not a lower-case slug of 1 to 40 letters, digits and _, starting with a letter');
117
+ }
118
+ for (const id of ids)
119
+ setOwn(out, id, kindSpec(id, v[id], `${path}.${id}`));
120
+ return out;
121
+ }
122
+ function resolveGuards(v, path) {
123
+ if (v === undefined)
124
+ return { perByWindowMs: PER_BY_DEFAULT_MS, newAccount: null };
125
+ if (!isPlain(v))
126
+ return fail(path, 'must be an object');
127
+ onlyKeys(v, GUARD_KEYS, path);
128
+ const per = given(v, 'perByWindowMs');
129
+ if (per !== undefined && !whole(per, PER_BY_MIN_MS, PER_BY_MAX_MS)) {
130
+ fail(`${path}.perByWindowMs`, `must be a whole number of milliseconds from ${PER_BY_MIN_MS} to ${PER_BY_MAX_MS}`);
131
+ }
132
+ const na = given(v, 'newAccount');
133
+ let newAccount = null;
134
+ if (na !== undefined && na !== null) {
135
+ const p = `${path}.newAccount`;
136
+ if (!isPlain(na))
137
+ return fail(p, 'must be an object with belowDays and factor, or null');
138
+ onlyKeys(na, NEW_ACCOUNT_KEYS, p);
139
+ const belowDays = given(na, 'belowDays');
140
+ if (!whole(belowDays, 1, NEW_ACCOUNT_DAYS_MAX))
141
+ fail(`${p}.belowDays`, `must be a whole number of days from 1 to ${NEW_ACCOUNT_DAYS_MAX}`);
142
+ const factor = given(na, 'factor');
143
+ if (!(typeof factor === 'number' && Number.isFinite(factor) && factor > 0 && factor <= 1))
144
+ fail(`${p}.factor`, 'must be a number above 0 and at most 1');
145
+ newAccount = { belowDays, factor };
146
+ }
147
+ return { perByWindowMs: per ?? PER_BY_DEFAULT_MS, newAccount };
148
+ }
149
+ function windowDays(v, path, ctx) {
150
+ if (!whole(v, 1, SIGNAL_WINDOW_DAYS_MAX))
151
+ fail(path, `must be a whole number of days from 1 to ${SIGNAL_WINDOW_DAYS_MAX}`, 'window');
152
+ if (v * DAY_MS > ctx.signalsMs)
153
+ fail(path, 'must not be longer than retention.signalsMs: rows older than that are deleted, so the window could never be met', 'window');
154
+ }
155
+ /** A list of declared kinds: 1 to `max`, each declared, no repeats; `negativeOnly` also refuses a positive kind. */
156
+ function kindList(v, path, ctx, max, negativeOnly) {
157
+ if (!Array.isArray(v) || v.length < 1 || v.length > max)
158
+ fail(path, `must list 1 to ${max} declared kinds`);
159
+ const seen = new Set();
160
+ v.forEach((id, i) => {
161
+ const p = `${path}[${i}]`;
162
+ const spec = typeof id === 'string' ? kindSpecOf(ctx.kinds, id) : undefined;
163
+ if (spec === undefined)
164
+ fail(p, 'is not a kind this game declared', 'unknown_kind');
165
+ if (negativeOnly && spec.polarity !== 'negative')
166
+ fail(p, 'is a positive kind: positive kinds may inform but never raise or boost', 'positive_kind');
167
+ if (seen.has(id))
168
+ fail(p, 'is listed twice');
169
+ seen.add(id);
170
+ });
171
+ }
172
+ function windowFeed(v, path, ctx) {
173
+ if (!isPlain(v))
174
+ return fail(path, 'must be an object with kinds and windowDays');
175
+ onlyKeys(v, WINDOW_FEED_KEYS, path);
176
+ const kinds = given(v, 'kinds');
177
+ if (kinds === undefined)
178
+ fail(`${path}.kinds`, 'is required');
179
+ if (kinds !== '*')
180
+ kindList(kinds, `${path}.kinds`, ctx, SIGNAL_KINDS_MAX + 1, false);
181
+ const days = given(v, 'windowDays');
182
+ if (days === undefined)
183
+ fail(`${path}.windowDays`, 'is required');
184
+ windowDays(days, `${path}.windowDays`, ctx);
185
+ }
186
+ function threshold(v, path, ctx, negativeOnly) {
187
+ if (given(v, 'kinds') === undefined)
188
+ fail(`${path}.kinds`, 'is required');
189
+ kindList(v['kinds'], `${path}.kinds`, ctx, THRESHOLD_KINDS_MAX, negativeOnly);
190
+ const minDistinct = given(v, 'minDistinct');
191
+ if (minDistinct === undefined)
192
+ fail(`${path}.minDistinct`, 'is required');
193
+ if (!whole(minDistinct, 1, MIN_DISTINCT_MAX))
194
+ fail(`${path}.minDistinct`, `must be a whole number from 1 to ${MIN_DISTINCT_MAX}`);
195
+ const days = given(v, 'windowDays');
196
+ if (days === undefined)
197
+ fail(`${path}.windowDays`, 'is required');
198
+ windowDays(days, `${path}.windowDays`, ctx);
199
+ const minWeight = given(v, 'minWeight');
200
+ if (minWeight !== undefined && !(typeof minWeight === 'number' && Number.isFinite(minWeight) && minWeight > 0 && minWeight <= MIN_WEIGHT_MAX)) {
201
+ fail(`${path}.minWeight`, `must be a number above 0 and at most ${MIN_WEIGHT_MAX}`);
202
+ }
203
+ }
204
+ function queueFeed(v, path, ctx) {
205
+ if (!isPlain(v))
206
+ return fail(path, 'must be an object with kinds, minDistinct and windowDays');
207
+ onlyKeys(v, THRESHOLD_KEYS, path);
208
+ threshold(v, path, ctx, true);
209
+ }
210
+ function ladderRule(v, path, ctx) {
211
+ if (!isPlain(v))
212
+ return fail(path, 'must be an object with an id, an effect and a threshold');
213
+ onlyKeys(v, RULE_KEYS, path);
214
+ const id = given(v, 'id');
215
+ if (typeof id !== 'string' || !RULE_ID_PATTERN.test(id))
216
+ fail(`${path}.id`, 'must be a lower-case id of 1 to 40 letters, digits, - and _');
217
+ const effect = given(v, 'effect');
218
+ if (effect !== 'note' && effect !== 'raise')
219
+ fail(`${path}.effect`, "must be 'note' or 'raise'");
220
+ threshold(v, path, ctx, effect === 'raise');
221
+ return id;
222
+ }
223
+ function ladderFeed(v, path, ctx) {
224
+ if (!Array.isArray(v))
225
+ return fail(path, 'must be a list of rules');
226
+ if (v.length > LADDER_RULES_MAX)
227
+ fail(path, `must list at most ${LADDER_RULES_MAX} rules`);
228
+ const ids = new Set();
229
+ v.forEach((rule, i) => {
230
+ const id = ladderRule(rule, `${path}[${i}]`, ctx);
231
+ if (ids.has(id))
232
+ fail(`${path}[${i}].id`, 'is used by another rule');
233
+ ids.add(id);
234
+ });
235
+ }
236
+ /**
237
+ * Check the feeds against the declared `kinds` and `opts.signalsMs` (the retention of signal rows, ms), throwing {@link ProfileError}
238
+ * whose path starts with `path` (`path.queue.kinds[0]`). A feed names declared kinds only; `queue` and a `raise` rule name negative
239
+ * kinds only; a count and a window are in range; a window is not longer than `signalsMs` (rows older than that are gone) or 90 days.
240
+ * @experimental
241
+ */
242
+ export function checkSignalFeeds(feeds, kinds, opts, path) {
243
+ if (feeds === undefined)
244
+ return;
245
+ if (!isPlain(feeds))
246
+ return fail(path, 'must be an object');
247
+ onlyKeys(feeds, SIGNAL_FEED_NAMES, path);
248
+ const ctx = { kinds, signalsMs: opts.signalsMs };
249
+ for (const name of SIGNAL_FEED_NAMES) {
250
+ const feed = given(feeds, name);
251
+ if (feed === undefined)
252
+ continue;
253
+ const p = `${path}.${name}`;
254
+ if (name === 'record' || name === 'ai')
255
+ windowFeed(feed, p, ctx);
256
+ else if (name === 'queue')
257
+ queueFeed(feed, p, ctx);
258
+ else
259
+ ladderFeed(feed, p, ctx);
260
+ }
261
+ }
262
+ /** The code for a failed check: the code the check itself put on its error (never the wording of a message), else `invalid`. */
263
+ function dropReason(err) {
264
+ const code = err instanceof ProfileError ? err.code : undefined;
265
+ return code === 'unknown_kind' || code === 'positive_kind' || code === 'window' ? code : 'invalid';
266
+ }
267
+ /**
268
+ * The feeds minus anything that can no longer be used: a feed (or a ladder rule) naming a kind the code stopped declaring, a positive
269
+ * kind where only negative ones are allowed, a window longer than `opts.signalsMs` or 90 days, or any other shape the checks refuse.
270
+ * Applied to a STORED layer at start-up, so one stale feed is dropped on its own and the rest of the layer (the ladder edits too) stays
271
+ * in force. Never throws: garbage in gives `{}`. `opts.onDrop` is told the name of each feed that lost something, once per feed, with
272
+ * the reason code of the first thing lost (a name that is not one of the four feeds is passed as it was stored, with `unknown_feed`: do
273
+ * not log it). The result passes {@link checkSignalFeeds}.
274
+ * @experimental
275
+ */
276
+ export function pruneSignalFeeds(feeds, kinds, opts) {
277
+ const out = {};
278
+ if (!isPlain(feeds))
279
+ return out;
280
+ const ctx = { signalsMs: opts.signalsMs };
281
+ const drop = (name, reason) => {
282
+ try {
283
+ opts.onDrop?.(name, reason);
284
+ }
285
+ catch {
286
+ // A broken callback must not stop the prune.
287
+ }
288
+ };
289
+ /** Null when the feed is usable, else the reason it is not. */
290
+ const unusable = (name, value) => {
291
+ try {
292
+ checkSignalFeeds({ [name]: value }, kinds, ctx, 'feeds');
293
+ return null;
294
+ }
295
+ catch (err) {
296
+ return dropReason(err);
297
+ }
298
+ };
299
+ for (const name of Object.keys(feeds)) {
300
+ const value = feeds[name];
301
+ if (!SIGNAL_FEED_NAMES.includes(name)) {
302
+ drop(name, 'unknown_feed');
303
+ continue;
304
+ }
305
+ if (name !== 'ladder') {
306
+ const why = unusable(name, value);
307
+ if (why === null)
308
+ setOwn(out, name, JSON.parse(JSON.stringify(value)));
309
+ else
310
+ drop(name, why);
311
+ continue;
312
+ }
313
+ if (!Array.isArray(value)) {
314
+ drop(name, 'invalid');
315
+ continue;
316
+ }
317
+ const kept = [];
318
+ const ids = new Set();
319
+ let lost = value.length > LADDER_RULES_MAX ? 'invalid' : null;
320
+ for (const rule of value.slice(0, LADDER_RULES_MAX)) {
321
+ const id = isPlain(rule) && typeof rule['id'] === 'string' ? rule['id'] : null;
322
+ const why = id === null || ids.has(id) ? 'invalid' : unusable(name, [rule]);
323
+ if (why === null) {
324
+ ids.add(id);
325
+ kept.push(JSON.parse(JSON.stringify(rule)));
326
+ }
327
+ else
328
+ lost ??= why;
329
+ }
330
+ if (lost !== null)
331
+ drop(name, lost);
332
+ if (kept.length > 0)
333
+ setOwn(out, name, kept);
334
+ }
335
+ return out;
336
+ }
337
+ // ---------------------------------------------------------------------------------------------------------------
338
+ /** A deep copy of validated feeds (plain data: strings, numbers, arrays and objects). */
339
+ function copyFeeds(feeds) {
340
+ return JSON.parse(JSON.stringify(feeds));
341
+ }
342
+ /**
343
+ * Validate the `signals` section and fill it in: the declared kinds merged over the built-ins, the guards with their defaults, the
344
+ * feeds as given. Throws {@link ProfileError} naming the field (`signals.kinds.x.label`), never echoing the value. The feeds are
345
+ * checked against the declared kinds and the 90 day cap here; the cross-check with `retention.signalsMs` is {@link checkSignalFeeds}'s
346
+ * job, called where the retention is known. The result shares nothing with the input, and resolving it again gives the same value.
347
+ * @experimental
348
+ */
349
+ export function resolveSignals(input, path = 'signals') {
350
+ if (input === undefined)
351
+ return { kinds: resolveKinds(undefined, `${path}.kinds`), guards: resolveGuards(undefined, `${path}.guards`), feeds: {} };
352
+ if (!isPlain(input))
353
+ return fail(path, 'must be an object');
354
+ onlyKeys(input, SETTINGS_KEYS, path);
355
+ const kinds = resolveKinds(given(input, 'kinds'), `${path}.kinds`);
356
+ const guards = resolveGuards(given(input, 'guards'), `${path}.guards`);
357
+ const feeds = given(input, 'feeds');
358
+ checkSignalFeeds(feeds, kinds, { signalsMs: Infinity }, `${path}.feeds`);
359
+ return { kinds, guards, feeds: feeds === undefined ? {} : copyFeeds(feeds) };
360
+ }
361
+ //# sourceMappingURL=signals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,yIAAyI;AACzI,oIAAoI;AACpI,kIAAkI;AAClI,EAAE;AACF,qIAAqI;AACrI,4DAA4D;AAE5D,MAAM,MAAM,GAAG,UAAU,CAAC;AAsI1B;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkE,UAAU,CAAC;IAC5G,eAAe,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAmB,EAAE;CAC9E,CAAC,CAAC;AAEH,oCAAoC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAC5D,yCAAyC;AACzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,mDAAmD;AACnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,cAAc,GAAG,gBAAgB,GAAG,UAAU,CAAC;AACrD,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,4BAA4B,CAAC;AACrD,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,aAAa,GAAG,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CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAC5D,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,QAAQ,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,OAAO,CAA4B,CAAC;IAC/D,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,QAAQ,CAAC,CAAC;IACzE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AAC/E,CAAC"}
@@ -61,6 +61,8 @@ export declare class SubjectIndex {
61
61
  * different subjects (not yet linked), the one a merge would keep (the older) is returned.
62
62
  */
63
63
  lookup(ids: Identifiers): SubjectId | null;
64
+ /** Has this index ever seen the subject id (a merged-away one included)? A pure read: it creates nothing. */
65
+ knows(id: SubjectId): boolean;
64
66
  /**
65
67
  * The surviving subject `id` was merged into, following the chain to the
66
68
  * root. An id the index has never seen is returned unchanged.
@@ -1 +1 @@
1
- {"version":3,"file":"subjects.d.ts","sourceRoot":"","sources":["../../src/subjects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,MAAM,EACN,KAAK,EACL,SAAS,EAGV,MAAM,YAAY,CAAC;AAiCpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,Q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KG;IACH,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI;IAe1C,6GAA6G;IAC7G,KAAK,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO;IAI7B;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS;IAcnC;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,EAAE;IAKrC;;;OAGG;IACH,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE;IAcnF;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI;IAgBtC,uFAAuF;IACjF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B,OAAO,CAAC,MAAM;IASd,mGAAmG;IACnG,OAAO,CAAC,KAAK;IAiBb,iEAAiE;IACjE,OAAO,CAAC,MAAM;IAiBd,4FAA4F;IAC5F,OAAO,CAAC,KAAK;IASb,sFAAsF;IACtF,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,UAAU;CAGnB"}
@@ -182,6 +182,10 @@ export class SubjectIndex {
182
182
  const keyWins = ck !== ca ? ck < ca : keyRoot < accountRoot;
183
183
  return keyWins ? keyRoot : accountRoot;
184
184
  }
185
+ /** Has this index ever seen the subject id (a merged-away one included)? A pure read: it creates nothing. */
186
+ knows(id) {
187
+ return typeof id === 'string' && this.created.has(id);
188
+ }
185
189
  /**
186
190
  * The surviving subject `id` was merged into, following the chain to the
187
191
  * root. An id the index has never seen is returned unchanged.