@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
@@ -1,3 +1,4 @@
1
+ import type { AIExample, AIRead, AISignal } from './ai/types.js';
1
2
  import type { AuditListQuery, AuditRow } from './audit.js';
2
3
  import type { PolicyLayer } from './profile.js';
3
4
  import type { RuleRef } from './rules.js';
@@ -189,6 +190,202 @@ export interface ReporterOutcomeRow {
189
190
  noAction: number;
190
191
  badFaith: number;
191
192
  }
193
+ /** Where an AI read stands. `pending` is owned by a lease; `skipped` means the daily limit (or the breaker) kept the call from being made. */
194
+ export type AiReadStatus = 'pending' | 'ok' | 'declined' | 'invalid' | 'failed' | 'skipped';
195
+ /** Why a read did not finish. `budget` belongs to a `skipped` read; `declined` and `invalid` to the statuses of the same name. */
196
+ export type AiErrorKind = 'retryable' | 'fatal' | 'declined' | 'timeout' | 'invalid' | 'budget';
197
+ /** A read about to be made: the input the lease is taken for. The store adds the id, the attempt count and the time. */
198
+ export interface AiReadPending {
199
+ reportId: string;
200
+ /** The input hash (design section 6); with `reportId` it is the UNIQUE key. */
201
+ inputHash: string;
202
+ promptVersion: number;
203
+ /** `ModerationAI.id` (never a key). */
204
+ adapter: string;
205
+ }
206
+ /** What one provider call used and cost: stored on a finished read, and on a failed one that still cost something. */
207
+ export interface AiCallUsage {
208
+ model: string;
209
+ inputTokens: number;
210
+ outputTokens: number;
211
+ cacheReadTokens: number;
212
+ cacheWriteTokens: number;
213
+ /** Integer micro-dollars. */
214
+ costMicros: number;
215
+ latencyMs: number;
216
+ }
217
+ /** The validated answer and the usage of the call that produced it. */
218
+ export interface AiReadDone extends AiCallUsage {
219
+ read: AIRead;
220
+ /**
221
+ * The ids of the casebook examples that were in the prompt (`AIStoredRead.exampleIds`): the examples are not part of the input
222
+ * hash, so the read records which ones it saw. Ids only; none by default.
223
+ */
224
+ exampleIds?: readonly string[];
225
+ /**
226
+ * The signal counts about the reported person the prompt carried (`feeds.ai`): exactly what was sent, label, polarity, distinct and window
227
+ * only. Stored with the read (`signals_json`); none (or an empty list) is stored as null.
228
+ */
229
+ signals?: readonly AISignal[];
230
+ }
231
+ /**
232
+ * One stored read, whatever its state. `read` is the validated answer, set only for `ok`; `leaseUntil` only while `pending`;
233
+ * `retryAt` for a `failed` or `skipped` read that may be tried again. It holds no chat text but the one-line summary and no
234
+ * identity.
235
+ */
236
+ export interface AiReadRow {
237
+ id: string;
238
+ reportId: string;
239
+ inputHash: string;
240
+ status: AiReadStatus;
241
+ /** Calls started for this row: 1 when reserved, +1 each time a lease or a retry is taken over. */
242
+ attempts: number;
243
+ retryAt: number | null;
244
+ leaseUntil: number | null;
245
+ errorKind: AiErrorKind | null;
246
+ adapter: string;
247
+ model: string | null;
248
+ promptVersion: number;
249
+ read: AIRead | null;
250
+ /** The ids of the casebook examples this read saw (empty when none, and for every row but an `ok` one). */
251
+ exampleIds: readonly string[];
252
+ /** The signal counts this read was shown (see {@link AiReadDone.signals}); null when none were sent, for every row but an `ok` one, and for a read made before signals existed. */
253
+ signals: readonly AISignal[] | null;
254
+ inputTokens: number | null;
255
+ outputTokens: number | null;
256
+ cacheReadTokens: number | null;
257
+ cacheWriteTokens: number | null;
258
+ /**
259
+ * The cost of the attempts that finished as this row's owner, summed. Tokens are summed too; `model` and `latencyMs` are the latest
260
+ * attempt's. A stale owner's paid call is booked only to the spend ledger, so this can be lower than the ledger: the daily cap reads the ledger.
261
+ */
262
+ costMicros: number;
263
+ latencyMs: number | null;
264
+ /** When the row was first reserved (a take-over keeps it). Spend is booked per attempt, not by this. */
265
+ createdAt: number;
266
+ /**
267
+ * True once a moderator's explicit "read again" has retaken this row (see `reserveAiRead` `opts.retake`). The explicit retake
268
+ * happens once per row, for good: it is a fact of the row, so a restart, a second process or any pruning cannot allow another.
269
+ */
270
+ retaken: boolean;
271
+ }
272
+ /**
273
+ * One signal a game recorded about a player (flood control and signals, design 5.8). Staff-side data: it holds ids and numbers only, no
274
+ * text, handle or seat. `sourceKey` is `b:<canonical by>`, `r:<roomId>` or `d:<UTC day>`; `(kind, subject, sourceKey, capBucket)` is unique,
275
+ * which is the per-source cap.
276
+ * @experimental
277
+ */
278
+ export interface SignalRow {
279
+ id: string;
280
+ kind: string;
281
+ subject: SubjectId;
282
+ /** 'b:<canonical by>' | 'r:<roomId>' | 'd:<UTC day>' */
283
+ sourceKey: string;
284
+ bySubject: SubjectId | null;
285
+ roomId: string | null;
286
+ at: number;
287
+ /** The effective weight, stored at record time (0 or more). */
288
+ weight: number;
289
+ /** floor(at / perByWindowMs): the cap bucket. */
290
+ capBucket: number;
291
+ }
292
+ /**
293
+ * What `listSignalSources` answers: one row per source of a kind about a subject. Rows are bounded by distinct sources, not by volume.
294
+ * @experimental
295
+ */
296
+ export interface SignalSourceRow {
297
+ subject: SubjectId;
298
+ kind: string;
299
+ sourceKey: string;
300
+ /** The source's `by` (the smallest, when rows of one source name more than one); null for a room or day source. */
301
+ bySubject: SubjectId | null;
302
+ /** The highest weight among the source's rows in range. */
303
+ weight: number;
304
+ firstAt: number;
305
+ lastAt: number;
306
+ }
307
+ /**
308
+ * The answer to a reserve: this caller owns the read now (`id`), or a row already exists for that report and input. `lease` is the
309
+ * caller's fence token (the row's `attempts` after this reserve): `completeAiRead` and `failAiRead` must be given it, and do nothing
310
+ * once another caller has taken the row over.
311
+ */
312
+ export type AiReserveResult = {
313
+ reserved: true;
314
+ id: string;
315
+ lease: number;
316
+ } | {
317
+ reserved: false;
318
+ existing: AiReadRow;
319
+ };
320
+ /** The human's verdict, and the AI's recommendation, in the casebook's three classes. */
321
+ export type AiVerdict = 'upheld' | 'noted' | 'no_action';
322
+ /**
323
+ * The finer facts of one outcome (design section 11): whether the verdict and the rule matched the AI, how many cited lines
324
+ * matched, whether the human step was the same, milder or harsher than the pre-fill (`none` when there was no pre-fill), and
325
+ * whether it was a one-click accept. Booleans, a count and a word: no text can be written into a row that outlives its report.
326
+ */
327
+ export interface AiOutcomeDetail {
328
+ verdict: boolean;
329
+ rule: boolean;
330
+ lines: number;
331
+ outcome: 'same' | 'milder' | 'harsher' | 'none';
332
+ oneClick: boolean;
333
+ }
334
+ /**
335
+ * One casebook row to insert: a decided report that had an AI read, computed by the server in the transaction of the decision.
336
+ * Ids, counts and the human's final choices; the only chat text is `example`, pseudonymised, kept on its own shorter clock.
337
+ */
338
+ export interface AiOutcomeInsert {
339
+ reportId: string;
340
+ /** The read the moderator was shown, or null when there was none. */
341
+ readId: string | null;
342
+ decidedAt: number;
343
+ /** The AI level in force when decided (1 or 2). */
344
+ level: number;
345
+ /** The human's final verdict. */
346
+ verdict: AiVerdict;
347
+ /** The human's final rule on the reported person (`'3'`, `'uncovered'`), or null. */
348
+ rule: string | null;
349
+ /** The conduct level the human settled on, when the form had one. */
350
+ severity: ConductLevel | null;
351
+ /** What the AI recommended, or null (level 1, or `unclear`). */
352
+ aiVerdict: AiVerdict | null;
353
+ agreement: 'agree' | 'override' | 'none';
354
+ detail: AiOutcomeDetail;
355
+ /** The report was dismissed as bad faith: excludes the row from examples. */
356
+ badFaith: boolean;
357
+ /** Up to 6 pseudonymised lines, or null for none. A store stores null for a `badFaith` row: it can never teach. */
358
+ example: AIExample | null;
359
+ }
360
+ /** A stored outcome: what was inserted, and the two marks a later action sets. */
361
+ export interface AiOutcomeRow extends AiOutcomeInsert {
362
+ /** Set by a granted appeal or a take-back. Excludes the row from examples (and drops its example text); counts as an AI false positive. */
363
+ reversed: boolean;
364
+ /** A senior's mark. Excludes the row from examples. */
365
+ dontTeach: boolean;
366
+ }
367
+ /** One teachable casebook example, newest first from {@link Store.aiExamples}. The human's final decision is the label. */
368
+ export interface AiExampleRow {
369
+ reportId: string;
370
+ decidedAt: number;
371
+ agreement: 'agree' | 'override';
372
+ example: AIExample;
373
+ }
374
+ /**
375
+ * The casebook counts for one rule (the human's final rule; `null` for none), for decisions at or after a time. `decided` is every
376
+ * outcome; `falsePositives` those where the AI recommended `upheld` or `noted` and the human settled on `no_action`, or the
377
+ * decision was later reversed.
378
+ */
379
+ export interface AiStatsRow {
380
+ rule: string | null;
381
+ decided: number;
382
+ agree: number;
383
+ override: number;
384
+ none: number;
385
+ falsePositives: number;
386
+ /** Decisions that were a one-click accept of the AI's pre-fill (the outcome detail's `oneClick`). */
387
+ oneClick: number;
388
+ }
192
389
  /**
193
390
  * One decided report a person filed that carried a reason, with what its decision did: for the reporter's accuracy. `reason` is
194
391
  * the report's stored `reportedReason`; `target` the reported subject as stored; `actions` one entry per sanction group the
@@ -609,7 +806,7 @@ export interface Store {
609
806
  * Reports that are still `open`, OLDEST first (`createdAt` ascending, then `id` ascending, so a tie is stable), whole
610
807
  * records. `category` filters; `after` keeps only reports newer than that instant (exclusive), and with `afterId` also
611
808
  * the ones filed AT that instant whose id sorts above it (keyset paging: pass the last row's `createdAt` and `id`).
612
- * `limit` is clamped to 1..200 (a fraction is floored). The scan behind "take next".
809
+ * `limit` is clamped to 1..200 (a fraction is floored); a limit that is not finite, or is below 1, counts as 1. The scan behind "take next".
613
810
  */
614
811
  listOpenReports(q: OpenReportQuery): ReportRecord[];
615
812
  /**
@@ -741,6 +938,130 @@ export interface Store {
741
938
  * inside `transaction`, so an undone transaction undoes it. It does not move the change token.
742
939
  */
743
940
  savePolicyLayer?(layer: PolicyLayer, expectedVersion: number): number | null;
941
+ /**
942
+ * OPTIONAL. Take the right to make one read, as ONE atomic conditional write: of two callers (two processes on one database
943
+ * included) for the same `reportId` and `inputHash`, exactly one gets `{ reserved: true }`; the other gets the existing row. A new
944
+ * row is `pending`, owned until `leaseUntil`, with `attempts` 1. An existing row is taken over (same id, `attempts` + 1, a new
945
+ * lease, `retryAt` and `errorKind` cleared, `createdAt` kept) only when it is `pending` and its lease has ended (`leaseUntil <= now`),
946
+ * or `failed` or `skipped` with a `retryAt` that has come (`retryAt <= now`), or `ok` with a stored answer that cannot be read. An
947
+ * `ok` (readable), `declined` or `invalid` row, a `failed` or `skipped` one with no `retryAt`, and a live lease are returned as
948
+ * `existing` (a copy). A win carries the fence token `lease` (= `attempts`), and opens one spend-ledger entry at `now` (one call
949
+ * started); `aiSpendSince` reads that ledger, so every attempt is booked to the time it was made. Does not move the change token.
950
+ * With `opts.retake` (a moderator's explicit "read again") a FINAL row (`declined`, `invalid`, or `failed` with no `retryAt`) is
951
+ * taken over too, once: the take-over sets the row's `retaken` marker and a row already marked is never retaken again. A `failed` row
952
+ * still waiting for its own retry time (`retryAt` set), an `ok` read and a live lease never are, so the three automatic attempts
953
+ * hold; the one explicit retake is the single extra attempt (a given-up row's is its fourth). A `skipped` row made no call and gave its
954
+ * attempt back, so an explicit ask takes it at once, whatever its `retryAt`, without using the marker.
955
+ */
956
+ reserveAiRead?(row: AiReadPending, leaseUntil: number, now: number, opts?: {
957
+ retake?: boolean;
958
+ }): AiReserveResult;
959
+ /**
960
+ * OPTIONAL. Store the validated read and the usage on a `pending` row: status `ok`, the lease cleared; cost and tokens are added to
961
+ * the row, and the cost to this attempt's ledger entry. `lease` is the token `reserveAiRead` returned. True only when this call did
962
+ * it; false (nothing changed) for an unknown row, one that is not `pending`, or one whose `attempts` is no longer `lease` (another
963
+ * caller took it over: a stale owner can neither finish nor fail the new owner's row). A stale owner's call was still paid for: its
964
+ * `result` cost is booked to its own attempt's ledger entry (once), and nothing else is touched. Moves the change token only on true.
965
+ */
966
+ completeAiRead?(id: string, lease: number, result: AiReadDone): boolean;
967
+ /**
968
+ * OPTIONAL. End a `pending` row without a read: `failed`, `declined`, `invalid` or `skipped`, with the kind of failure and, for
969
+ * a retry, the time it may be taken again (`retryAt`; null is final). The lease is cleared. `usage`, when the provider still
970
+ * charged for the call (a refusal, an invalid answer, a failure after tokens were billed), is added to the row and to this attempt's
971
+ * ledger entry, so it counts toward `aiSpendSince`. A `skipped` read was never a call: its ledger entry is removed and the attempt is given back (a skip does not use up the three-attempt budget). `lease` fences as
972
+ * in `completeAiRead`, including the booking of a stale owner's `usage`. True when this call did it; false for an unknown row, one that
973
+ * is not `pending`, or a stale `lease`. Does not move the change token.
974
+ */
975
+ failAiRead?(id: string, lease: number, status: 'failed' | 'declined' | 'invalid' | 'skipped', errorKind: AiErrorKind, retryAt: number | null, usage?: AiCallUsage): boolean;
976
+ /**
977
+ * OPTIONAL. The newest `ok` read of the report (`createdAt` descending, then `id` descending), whatever its input hash; null
978
+ * when there is none. A row whose stored answer cannot be read is skipped. Pending, failed, declined, invalid and skipped rows
979
+ * are never returned.
980
+ */
981
+ loadAiRead?(reportId: string): AiReadRow | null;
982
+ /**
983
+ * OPTIONAL. The newest `ok` read of each of these reports (one row per report that has one), in the order the ids first appear.
984
+ * At most the first 200 distinct ids are looked at; unknown ids give nothing.
985
+ */
986
+ loadAiReads?(reportIds: readonly string[]): AiReadRow[];
987
+ /**
988
+ * OPTIONAL. One read by its id, whatever its state (a copy), or null for an unknown id. The decision's echo names the read the
989
+ * moderator was shown; the caller checks that it belongs to the report and is `ok`.
990
+ */
991
+ loadAiReadById?(id: string): AiReadRow | null;
992
+ /**
993
+ * OPTIONAL. The row for this report and this input hash (the pair is unique), whatever its state (a copy), or null. "Read again"
994
+ * looks at it to tell a final row, which an explicit ask may retake once (`retaken`), from one still waiting for its own retry.
995
+ */
996
+ loadAiReadFor?(reportId: string, inputHash: string): AiReadRow | null;
997
+ /**
998
+ * OPTIONAL. The rows the sweeper should pick up at `now`, oldest first (`createdAt`, then `id`), at most `limit` (clamped to
999
+ * 1..200): `failed` or `skipped` rows whose `retryAt` has come (`retryAt <= now`), and `pending` rows whose lease has ended
1000
+ * (`leaseUntil <= now`: the process that held them died). Rows of reports that have been decided are left out: nobody will read them. `limit` is clamped to 1..200 (a fraction is floored); one that is omitted, not finite or below 1 is the default of 20 (what the sweeper enqueues at a time).
1001
+ */
1002
+ listAiRetries?(now: number, limit: number | undefined): AiReadRow[];
1003
+ /**
1004
+ * OPTIONAL. What the attempts made at or after `since` cost: the sum of their `costMicros` (a failed attempt with usage included),
1005
+ * and the number of calls (every attempt but a skipped one, a `pending` one included). Each attempt counts at the time it was
1006
+ * reserved, so a retry that crosses UTC midnight books each attempt to its own day. The daily cap is this with `since` = the UTC
1007
+ * midnight.
1008
+ */
1009
+ aiSpendSince?(since: number): {
1010
+ micros: number;
1011
+ calls: number;
1012
+ };
1013
+ /**
1014
+ * OPTIONAL. Record the outcome of a decided report. False, nothing written, when the report already has one. A `badFaith` row is
1015
+ * stored without its example (it can never teach). Does not move the change token (the decision it belongs to does).
1016
+ */
1017
+ insertAiOutcome?(row: AiOutcomeInsert): boolean;
1018
+ /** OPTIONAL. The report's outcome, or null. Returns a copy; an unreadable `detail` reads as `{}` and an unreadable example as null. */
1019
+ loadAiOutcome?(reportId: string): AiOutcomeRow | null;
1020
+ /**
1021
+ * OPTIONAL. Set the marks on an outcome (a mark is never cleared) and drop its example text in the same write: a reversed or marked
1022
+ * row can never teach, so its chat text goes now. False for an unknown report. Moves the change token when the report has an outcome.
1023
+ */
1024
+ markAiOutcome?(reportId: string, patch: {
1025
+ reversed?: true;
1026
+ dontTeach?: true;
1027
+ }): boolean;
1028
+ /**
1029
+ * OPTIONAL. Teachable examples with this human rule (`'3'`, `'uncovered'`) and conduct level, decided at or after `since`, newest
1030
+ * first (`decidedAt` descending, then `reportId` descending), at most `limit`. Teachable: an example is
1031
+ * stored, the AI recommended something (`agree` or `override`, not `none`), and the row is not `reversed`, `dontTeach` or `badFaith`.
1032
+ * `limit` is clamped to 1..200 (a fraction is floored); one that is omitted, not finite or below 1 is the default of 2 (the prompt takes at most two
1033
+ * examples).
1034
+ */
1035
+ aiExamples?(rule: string, severity: string, limit: number | undefined, since: number): AiExampleRow[];
1036
+ /** OPTIONAL. How many teachable examples (see `aiExamples`) were decided at or after `since`. */
1037
+ aiTeachableCount?(since: number): number;
1038
+ /**
1039
+ * OPTIONAL. The casebook counts per rule for decisions at or after `since`: numbered rules in number order, then `'uncovered'`,
1040
+ * then no rule. A rule with no decision is left out.
1041
+ */
1042
+ aiStats?(since: number): AiStatsRow[];
1043
+ /**
1044
+ * OPTIONAL. Retention for the AI rows, all strict (`<`): reads created before `readsBefore` (any status), outcomes decided before
1045
+ * `outcomesBefore`, and the example of every outcome decided before `examplesBefore` (set to none; the counts stay); spend-ledger
1046
+ * entries made before `readsBefore` go with the reads. Returns how many reads and outcomes were deleted. `purgeReports` deletes the reads of the reports it deletes itself.
1047
+ */
1048
+ purgeAi?(readsBefore: number, outcomesBefore: number, examplesBefore: number): {
1049
+ reads: number;
1050
+ outcomes: number;
1051
+ };
1052
+ /**
1053
+ * OPTIONAL. Insert one signal as ONE atomic statement: false, and nothing written, when a row with the same `(kind, subject, sourceKey,
1054
+ * capBucket)` exists (the per-source cap; of two callers, two processes on one database included, exactly one writes) or the id is
1055
+ * taken. True when a row was written.
1056
+ */
1057
+ insertSignal?(row: SignalRow): boolean;
1058
+ /**
1059
+ * OPTIONAL. One row per `(subject, kind, sourceKey)` that has a row at or after `since`, for these subjects (a person's canonical id and
1060
+ * aliases): the highest weight, the earliest and the latest `at` among the rows in range. No subjects: `[]`. Returns copies.
1061
+ */
1062
+ listSignalSources?(subjects: readonly SubjectId[], since: number): SignalSourceRow[];
1063
+ /** OPTIONAL. Delete rows with `at < before` (a row exactly on the line is kept); returns how many. */
1064
+ purgeSignals?(before: number): number;
744
1065
  /**
745
1066
  * Insert one audit entry. A duplicate id throws (nothing is written). Both json columns are written NULL. A policy row
746
1067
  * (`policy.update`, `policy.reset`) also carries `detail` (the sections changed and the owner's reason): a store MUST keep it
@@ -764,7 +1085,8 @@ export interface Store {
764
1085
  /**
765
1086
  * Delete reports with `createdAt < before`, except a bad-faith dismissal still inside its window
766
1087
  * (`bad_faith = 1` and `actionedAt >= keepBadFaithSince`): the reporter's suspension reads it. Also deletes the
767
- * recorded decisions of reports that no longer exist. Returns how many reports it deleted.
1088
+ * recorded decisions of reports that no longer exist, and the AI reads of the reports it deletes (not their casebook outcomes: those
1089
+ * have their own clock, see `purgeAi`). Returns how many reports it deleted.
768
1090
  */
769
1091
  purgeReports(before: number, keepBadFaithSince: number): number;
770
1092
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM1C;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kCAAkC;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,EAAE,CA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AAI,CAAC;CACrD;AAMD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE;QAAE,IAAI,EAAE,gBAAgB,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;CACxG"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4BAA4B;AAgQ5B,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAA4B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC,CAAC;AA2KvH,8EAA8E;AAC9E,iEAAiE;AACjE,8EAA8E;AAE9E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA+C3C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4BAA4B;AAid5B,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAA4B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC,CAAC;AA2KvH,8EAA8E;AAC9E,iEAAiE;AACjE,8EAA8E;AAE9E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA+C3C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatwarden/core",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "description": "Chat moderation engine for games: reports, warnings, timeouts and bans, a moderator queue and player notices. No sockets, HTTP or disk.",
6
6
  "license": "Apache-2.0",
@@ -43,7 +43,7 @@
43
43
  "prepack": "tsc -b"
44
44
  },
45
45
  "devDependencies": {
46
- "@chatwarden/store-memory": "0.1.6"
46
+ "@chatwarden/store-memory": "0.1.8"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -0,0 +1,106 @@
1
+ import type { AiOutcomeDetail, AiVerdict, SanctionKind } from '../types.js';
2
+ import type { AIRead } from './types.js';
3
+
4
+ // Agree or override (design section 11). Pure: it compares the stored read with what the human decided and nothing else. What a client
5
+ // says it did (the `accepted` echo) is kept as the one-click fact and never decides anything.
6
+
7
+ /** A step as a person would take it: a kind and a length (null for a warning, a note or a permanent one). */
8
+ export interface StepLike {
9
+ kind: SanctionKind;
10
+ durationMs: number | null;
11
+ }
12
+
13
+ /** What the human decided about the reported person, as the server sees it. */
14
+ export interface HumanDecision {
15
+ verdict: 'upheld' | 'noted' | 'no_action' | 'bad_faith';
16
+ /** The Community Rule the human cited against the reported person, or null (a dismissal). */
17
+ rule: number | 'uncovered' | null;
18
+ /** The ids of the reported person's lines the human cited. */
19
+ lineIds: readonly string[];
20
+ /** The strongest step the human took against the reported person, or null. */
21
+ step: StepLike | null;
22
+ /** The step the ladder gives for the AI's conduct level: what the pre-fill would have been; null when there was none. */
23
+ prefill: StepLike | null;
24
+ /** How many actions the decision took on people other than the reported person (the reporter, a bystander); absent means none. */
25
+ others?: number;
26
+ /** The client says the moderator accepted the pre-fill in one click. A claim: the server counts it only when the decision is the pre-fill (see {@link agreementOf}). */
27
+ oneClick: boolean;
28
+ }
29
+
30
+ /** The result: the class of agreement, the AI's verdict in the casebook's three classes, and the finer facts. */
31
+ export interface Agreement {
32
+ agreement: 'agree' | 'override' | 'none';
33
+ /** What the AI recommended, or null when no recommendation was shown (level 1, `unclear`, or no read). */
34
+ aiVerdict: AiVerdict | null;
35
+ detail: AiOutcomeDetail;
36
+ }
37
+
38
+ const KIND_RANK: Record<SanctionKind, number> = { note: 1, warning: 2, chat: 3, area: 4, ban: 5 };
39
+
40
+ /** How long a step lasts for ordering: no length for a note or warning, and a permanent restriction or ban beyond any length. */
41
+ function lengthOf(s: StepLike): number {
42
+ if (s.kind === 'note' || s.kind === 'warning') return 0;
43
+ return s.durationMs === null ? Number.POSITIVE_INFINITY : s.durationMs;
44
+ }
45
+
46
+ /**
47
+ * Order two steps by how heavy they are: none, a note, a warning, a chat restriction, a ban from public rooms, a full ban; within a
48
+ * kind, by length (permanent last). Negative when `a` is milder than `b`, zero when equal, positive when `a` is harsher.
49
+ */
50
+ export function compareSteps(a: StepLike | null, b: StepLike | null): number {
51
+ const kindA = a === null ? 0 : (KIND_RANK[a.kind] ?? 0);
52
+ const kindB = b === null ? 0 : (KIND_RANK[b.kind] ?? 0);
53
+ if (kindA !== kindB) return kindA < kindB ? -1 : 1;
54
+ if (a === null || b === null) return 0;
55
+ const x = lengthOf(a);
56
+ const y = lengthOf(b);
57
+ return x < y ? -1 : x > y ? 1 : 0;
58
+ }
59
+
60
+ const NO_DETAIL: AiOutcomeDetail = { verdict: false, rule: false, lines: 0, outcome: 'none', oneClick: false };
61
+
62
+ /**
63
+ * The decision is the pre-fill as it stood: the same kind of step, no longer than the pre-fill (a moderator may trim a length and it is
64
+ * still their one click), or both without a step (a dismissal accepted as one).
65
+ */
66
+ function stepAccepted(step: StepLike | null, prefill: StepLike | null): boolean {
67
+ if (step === null || prefill === null) return step === null && prefill === null;
68
+ if (step.kind !== prefill.kind) return false;
69
+ if (step.durationMs === prefill.durationMs) return true;
70
+ return step.durationMs !== null && prefill.durationMs !== null && step.durationMs <= prefill.durationMs;
71
+ }
72
+
73
+ /**
74
+ * Compare the AI's recommendation in `read` with `decision`. `level` is the AI level in force: below 2 the recommendation was not
75
+ * shown, so there is nothing to agree with (`none`). `upheld` and `noted` are one class (the AI wanted to act, or to record);
76
+ * `no_action` is the other; a `bad_faith` verdict is always an override of a recommendation (the AI can never call a report bad faith).
77
+ * A rule that differs is not a disagreement: it is `rule: false` in the detail (and for a `no_action` the rule means nothing: `true`).
78
+ * `detail.oneClick` is the server's verdict, not the client's claim: true only when the client said so AND the decision is an
79
+ * agreement that equals the pre-fill (the same verdict, the same rule, the same kind of step and no longer) and the decision takes no
80
+ * action on anyone else: a decision that also sanctions the reporter or a bystander is the moderator's own, not the AI's one key.
81
+ */
82
+ export function agreementOf(read: AIRead | null, decision: HumanDecision, level: 0 | 1 | 2 = 2): Agreement {
83
+ const rec = read?.recommendation ?? null;
84
+ if (level < 2 || rec === null || rec.verdict === 'unclear') {
85
+ return { agreement: 'none', aiVerdict: null, detail: { ...NO_DETAIL } };
86
+ }
87
+ const aiVerdict: AiVerdict = rec.verdict;
88
+ const aiActs = aiVerdict === 'upheld' || aiVerdict === 'noted';
89
+ const humanActs = decision.verdict === 'upheld' || decision.verdict === 'noted';
90
+ const same = decision.verdict !== 'bad_faith' && aiActs === humanActs;
91
+ const cited = new Set(rec.evidence);
92
+ const lines = new Set(decision.lineIds.filter((id) => cited.has(id))).size;
93
+ const cmp = compareSteps(decision.step, decision.prefill);
94
+ const ruleMatches = aiVerdict === 'no_action' || rec.rule === decision.rule;
95
+ return {
96
+ agreement: same ? 'agree' : 'override',
97
+ aiVerdict,
98
+ detail: {
99
+ verdict: same,
100
+ rule: ruleMatches,
101
+ lines,
102
+ outcome: cmp === 0 ? 'same' : cmp < 0 ? 'milder' : 'harsher',
103
+ oneClick: decision.oneClick && same && rec.verdict === decision.verdict && ruleMatches && (decision.others ?? 0) === 0 && stepAccepted(decision.step, decision.prefill),
104
+ },
105
+ };
106
+ }
@@ -0,0 +1,73 @@
1
+ // The breaker (design section 4, "A breaker"). Five consecutive failures, or any `fatal`, stop new calls for five minutes; then
2
+ // ONE probe call decides: its success closes the breaker, its failure opens it for another five minutes. While it is open nothing is
3
+ // called. A refusal (`declined`) or an unusable answer (`invalid`) is an answer, so it counts as a success here: the provider is up.
4
+
5
+ /** Consecutive failures that open the breaker. */
6
+ export const BREAKER_THRESHOLD = 5;
7
+ /** How long an open breaker refuses calls before one probe is let through. */
8
+ export const BREAKER_OPEN_MS = 5 * 60_000;
9
+
10
+ /** Whether a call may be made now: freely, as the one probe, or not at all. */
11
+ export type BreakerGate = 'go' | 'probe' | 'no';
12
+
13
+ /** What the hub shows: `closed` is working, `open` and `half_open` are "unavailable". */
14
+ export type BreakerState = 'closed' | 'open' | 'half_open';
15
+
16
+ export class Breaker {
17
+ private failures = 0;
18
+ private openUntil: number | null = null;
19
+ private probing = false;
20
+
21
+ private readonly clock: { now(): number };
22
+
23
+ constructor(clock: { now(): number }) {
24
+ this.clock = clock;
25
+ }
26
+
27
+ /** Ask to make a call. A `probe` is handed out once; report its end with {@link success}, {@link failure} or {@link release}. */
28
+ gate(): BreakerGate {
29
+ if (this.openUntil === null) return 'go';
30
+ if (this.clock.now() < this.openUntil) return 'no';
31
+ if (this.probing) return 'no';
32
+ this.probing = true;
33
+ return 'probe';
34
+ }
35
+
36
+ /** Whether a call could go out now: closed, or half-open with the probe free. Takes nothing (see {@link gate}). */
37
+ available(): boolean {
38
+ if (this.openUntil === null) return true;
39
+ return this.clock.now() >= this.openUntil && !this.probing;
40
+ }
41
+
42
+ state(): BreakerState {
43
+ if (this.openUntil === null) return 'closed';
44
+ return this.clock.now() < this.openUntil ? 'open' : 'half_open';
45
+ }
46
+
47
+ /** When an open breaker lets the probe through (epoch ms), or null when closed. */
48
+ reopensAt(): number | null {
49
+ return this.openUntil;
50
+ }
51
+
52
+ /** A call produced an answer (even a refusal or an unusable one). Closes the breaker. */
53
+ success(): void {
54
+ this.failures = 0;
55
+ this.openUntil = null;
56
+ this.probing = false;
57
+ }
58
+
59
+ /** A call failed. `fatal` opens at once; so does a failed probe and the fifth failure in a row. */
60
+ failure(fatal = false): void {
61
+ this.failures += 1;
62
+ if (fatal || this.probing || this.failures >= BREAKER_THRESHOLD) {
63
+ this.openUntil = this.clock.now() + BREAKER_OPEN_MS;
64
+ this.failures = 0;
65
+ }
66
+ this.probing = false;
67
+ }
68
+
69
+ /** A probe was handed out but no call came of it (for example the budget stopped it): let the next ask be the probe. */
70
+ release(): void {
71
+ this.probing = false;
72
+ }
73
+ }