@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
package/README.md CHANGED
@@ -110,9 +110,10 @@ For the moderators' screens and the player's notices, mount the routes in
110
110
 
111
111
  | Part | What it is for |
112
112
  | --- | --- |
113
- | `cw.rooms` | `seat`, `seatConnection`, `unseat`, `close`: who is in which seat of which room. |
113
+ | `cw.rooms` | `seat`, `seatConnection`, `unseat`, `close`: who is in which seat of which room. `setPace(roomId, pace)` and `pace(roomId)` (`@experimental`) give one room its own slow mode, burst limit and repeat rule, in this process only. See "Slow mode and flood control". |
114
114
  | `cw.chat.accept(room, seat, text)` | The answer for one line: `{ deliver }` or `{ refuse: { reason } }`. `visibleTo` applies a viewer's mutes. `restricted(who)` says whether a person is chat-restricted, for typing indicators; `restrictedBySubject(subject)` (`@experimental`) says the same for a subject id from `cw.rooms.subjectAt`, so a server that keeps a connection open need not keep the player's key to ask again. |
115
115
  | `cw.mutes` | A player mutes another player for themselves only. |
116
+ | `cw.signals` | `@experimental`. What your game records about a player, counted by distinct source: `record`, `counts`, `kinds`, `boosted`, `forRecord`. See "Signals". |
116
117
  | `cw.reports` | `submit` and `addDetail` (players; see "Reporting settings"), `list`, `get` and `reporterRecord` (staff). `reporterRecord(person)` is how the reports a person filed stand: `{ reports, open, actioned, dismissed, badFaith, suspendedUntil, reasonMatched, reasonDecided, accuracy }`. `reporterAccuracy(people)` is how often each person's recent reports turned out to be unfounded (see "Reporter accuracy"). |
117
118
  | `cw.decide(input)` | A moderator closes a report and writes the sanctions and notices in one transaction. Safe to send twice. `reason` is required, except for a `no_action` with no actions (a one-click dismissal): leave it out and the standard reason `NO_ACTION_DEFAULT_REASON` (`No action needed`) is stored. |
118
119
  | `cw.sanctions` | `apply` and `revoke`, for a moderator who acts without a report. `forPerson(subject)` and `list({ cursor?, limit?, source? })` (staff) read sanctions as `SanctionGroupView`s: one per group, built from the person's own row, so no IP, hash or stored value is in them. |
@@ -126,7 +127,7 @@ For the moderators' screens and the player's notices, mount the routes in
126
127
  | `cw.names.check` | May a player use this as a name? |
127
128
  | `cw.history`, `cw.suggest` | A person's recent record, and what the preset suggests as the next step. |
128
129
  | `cw.rules`, `cw.profile`, `cw.limits`, `cw.summary`, `cw.documents` | The rules, standard and numbers in force, and the written code of conduct and guides. `cw.profile` and `cw.summary` are read live: the profile in force is your code's profile with the owner's stored edits on top (see "The editable profile"), so read it when you need it and never keep it. |
129
- | `cw.policy` | The editable profile: `get`, `save`, `preview`, `reset` and `refresh`. The lengths a moderator is offered, the ladder, the first offences, the repeat rule, the area and severe rules and the guideline outcome texts can be edited at runtime and are stored in your store. |
130
+ | `cw.policy` | The editable profile: `get` (it also reports `limits`, read only: the chat rate in force and the signals retention), `save`, `preview`, `reset` and `refresh`. The lengths a moderator is offered, the ladder, the first offences, the repeat rule, the area and severe rules and the guideline outcome texts can be edited at runtime and are stored in your store. |
130
131
  | `cw.gaps`, `cw.audit` | Rule gaps for the periodic review, and the staff audit trail. |
131
132
  | `cw.on(type, listener)` | Events: `report.created`, `report.closed`, `sanction.applied`, `sanction.revoked`, `gap.created`, `auto.restricted`. |
132
133
  | `cw.purge`, `cw.ready`, `cw.flush`, `cw.close` | Housekeeping. |
@@ -190,6 +191,9 @@ cw.policy.reset('durations'); // put one section back to the base; reset() puts
190
191
  cannot be used: it is then ignored, the base stays in force, and one `chatwarden.policy_layer_invalid` line is logged. `kind` is `'unreadable'`
191
192
  when the stored text could not be read at all (corrupted, not JSON, not an object), so the owner's edits are gone until they save again, and
192
193
  `'invalid'` when it was read but a setting is not valid (a field from a newer kit, say). A save or a full `reset()` repairs either.
194
+ `layer` is the layer in force: a stored signal feed that can no longer be used (its kind is no longer declared in code, or its window is longer
195
+ than `retention.signalsMs` now allows) is dropped alone, the rest of the layer stays, and `dropped` (`[{ feed, reason }]`, a feed name and a reason
196
+ code, never a kind or a rule id; `@experimental`) says what went. Send `layer` back to `save` and it is accepted and repairs the stored row.
193
197
  - **`save(layer, { version, actor, reason })`** stores the whole layer: a section you leave out goes back to the base. It answers
194
198
  `{ ok: true, version, changed }`, `{ ok: false, error: 'conflict' }` for a stale `version` (nothing is written),
195
199
  `{ ok: false, error: 'invalid', path }` for a layer that touches a setting that is not editable or would make the profile invalid
@@ -276,6 +280,170 @@ const res = await cw.reports.addDetail(reportId, 'seat-1', { reason: 'cheating',
276
280
  - **Your own store.** `addReportDetail` and `loadReporterDecisions` are optional on `Store`. Without the first, `addDetail` answers `off`; without the
277
281
  second, the accuracy counts are 0. `insertReport` must keep `reportedReason`, and `listReports` must apply the `reason` filter (`null` means none).
278
282
 
283
+ ## What is experimental in 0.1.8
284
+
285
+ These may change before 0.2, and are marked `@experimental` in the types: `PaceSettings`, `ResolvedPace`, `resolvePace`, `mergePace`, `checkPace`,
286
+ `PACE_SUGGESTIONS`, `cw.rooms.setPace`, `cw.rooms.pace`, `cw.signals` and every signal type (`SignalInput`, `SignalCount`, `SignalSettings`, the feeds,
287
+ `PolicyDropped`, `PolicyLimits`, `PolicyState.limits` and `.dropped`), `SuggestContext.hideSignalText`, `Suggestion.signals`, `signalBoost` in
288
+ `cw.cases.next`, `BUILTIN_SIGNAL_KINDS`, `withMemorySignals`, the `pace` prop of `RestrictedChatLine` and `secondsLeft` in `@chatwarden/player-react`.
289
+
290
+ ## Slow mode and flood control
291
+
292
+ Optional and off until you set it, `@experimental` until 0.2 and new in 0.1.8. Three checks pace one player's lines in one room: **slow mode**
293
+ (at least `slowModeMs` between lines, 500 to 600 000), a **burst limit** (at most `burst.lines` lines in any `burst.windowMs`: 2 to 100 lines
294
+ in 1 000 to 600 000 ms) and **repeats** (the same line again inside `duplicateWindowMs`, 1 000 to 3 600 000, is refused). Set them in code with
295
+ `overrides.pace`, or the owner sets them in the hub (Settings, Advanced, "Slow mode and flooding"); the stored layer wins over code. The presets set
296
+ nothing, so no install changes by itself.
297
+
298
+ ```ts
299
+ import { createChatwarden } from '@chatwarden/core';
300
+ import { createMemoryStore } from '@chatwarden/store-memory';
301
+
302
+ const cw = await createChatwarden({
303
+ store: createMemoryStore(),
304
+ secret: 'a-long-random-secret',
305
+ platform: { identify: (ctx) => ctx as { clientKey: string } },
306
+ overrides: { pace: { slowModeMs: 2000, burst: { lines: 6, windowMs: 10_000 }, duplicateWindowMs: 15_000 } },
307
+ });
308
+
309
+ // One room that differs, in this process, until the room closes: a tournament final is slower, a practice room is not paced at all.
310
+ cw.rooms.setPace('tournament:final', { slowModeMs: 3000 });
311
+ cw.rooms.setPace('practice', { slowModeMs: null, burst: null, duplicateWindowMs: null });
312
+ console.log(cw.rooms.pace('tournament:final')); // the pace in force there: the defaults with the override on top
313
+ ```
314
+
315
+ - **A refusal, not a sanction.** `cw.chat.accept` answers `{ refuse: { reason, retryAfterMs } }` with `reason` `'slow_mode'`, `'flood'` or
316
+ `'duplicate'`, and `retryAfterMs` (at least 1) is when the same player may try again, in milliseconds from now. There is no rule, no notice and no
317
+ text with it. **A new refusal reason**: a `switch (reason)` that ends in `assertNever` will not compile until it handles the three, though a kit
318
+ can only send them after you turn pacing on. The staff routes and the chat box carry them through (`@chatwarden/http`, `@chatwarden/player-react`).
319
+ - **The order.** After the length check and before the fixed rate limit, so a player hammering a slow-mode room reads "slow mode" and not "too fast". A
320
+ line the fixed rate refuses does not count toward pacing, and a refusal never changes pacing state (repeating a refused line cannot extend its own
321
+ block). Repeats compare the line with letters and digits only, case and width folded and combining marks kept, so `gg` and `ok` (under three
322
+ characters) are never repeats; only a short digest is kept, never the text.
323
+ - **Per process.** Pacing state lives in memory in the process that serves the room and is lost on restart, like the fixed rate limit. Route a room's
324
+ chat to one process for the full effect; send one player's lines to several and the effective limit is up to that many times looser. Nothing is shared
325
+ or written, by design: a store round trip per line is the cost this exists to avoid. At most 50 000 (room, player) states are kept (`PACE_KEYS_MAX`).
326
+ `cw.rooms.setPace` is per process as well: call it where you create the room, in each process that serves it.
327
+ - **A burst looser than the fixed limit never triggers.** `limits.chatRate` (3 per 5 seconds by default) answers first inside the same window; the hub
328
+ says so beside the field, with the real numbers (`cw.policy.get().limits.chatRate`).
329
+ - **Flooding is remembered.** When the burst limit trips, the built-in signal `flood_triggered` ("Flooded the chat") is recorded for that player in that
330
+ room, at most once a window, whether or not you declared any signals (see "Signals"). It needs a store with the signal methods, else it is skipped.
331
+ - **Suggested values.** `PACE_SUGGESTIONS` (relaxed: burst 10 in 10 s, repeats 10 s; standard: 6 in 10 s, 15 s; strict: slow mode 2 s, 5 in 10 s, 30 s) is
332
+ what the hub's "Use suggested values" button fills in; nothing applies them by itself. `resolvePace`, `mergePace` and `checkPace` validate and merge.
333
+ - **To try it**, run `examples/tiny-chat` with `CW_DEMO_PACE=1` (a 2 second slow mode) and open the page.
334
+
335
+ ## Signals
336
+
337
+ Optional, `@experimental` until 0.2 and new in 0.1.8. A signal is one fact your game records about a player ("muted by another player", "kicked from a
338
+ room", "left mid-game"). The kit counts them by distinct source and shows the counts where a profile rule says so. **A signal never acts on its own: it
339
+ never writes a sanction, a mute or a notice, and a person always decides.** Nothing is recorded or shown until you declare kinds and switch a feed on.
340
+
341
+ ```ts
342
+ import { createChatwarden } from '@chatwarden/core';
343
+ import { openStore } from '@chatwarden/store-sqlite';
344
+
345
+ const cw = await createChatwarden({
346
+ store: openStore({ path: './chatwarden.db' }),
347
+ secret: process.env.CHATWARDEN_SECRET!,
348
+ platform: { identify: (ctx) => ctx as { clientKey: string } },
349
+ overrides: {
350
+ signals: {
351
+ kinds: {
352
+ muted_by_player: { label: 'Muted by other players', polarity: 'negative' },
353
+ kicked_from_room: { label: 'Kicked from a room', polarity: 'negative', weight: 2 },
354
+ commended: { label: 'Commended by other players', polarity: 'positive' },
355
+ },
356
+ feeds: { record: { kinds: '*', windowDays: 14 } },
357
+ },
358
+ },
359
+ });
360
+
361
+ // From the game's own events, never from every chat line: one small write each.
362
+ const player = { clientKey: 'a-client-key' };
363
+ const muter = { clientKey: 'another-client-key' };
364
+ cw.signals.record({ kind: 'muted_by_player', subject: player, by: muter, roomId: 'lobby-7' });
365
+ console.log(cw.signals.counts(cw.rooms.subjectAt('lobby-7', 'p1') ?? 's_unknown'));
366
+ ```
367
+
368
+ - **Kinds are code.** A kind id is a lower-case slug (`muted_by_player`); the label is plain text, 1 to 60 characters; `polarity` is `'negative'` or `'positive'`;
369
+ `weight` is 0 to 10 (default 1). The kit declares one itself, `flood_triggered`, which you may relabel or re-weight but not make positive.
370
+ - **`cw.signals.record(input)`** is synchronous, fenced and never throws: it returns `true` when a row was written and `false` for any refusal
371
+ (logged by reason code, at most once a minute, never an id). `subject` and `by` are a subject id the kit already knows or a `RawWho`
372
+ (`{ clientKey?, accountId?, ip? }`, each under 513 characters) that it has already seen: a stranger is refused, never created. `by`, `roomId` and `at`
373
+ may be left out or `null`. A player cannot signal themselves (also across a merge), `at` may not be more than 5 minutes ahead or older than the
374
+ retention, and `roomId` is the game's own id: 1 to 64 of `A-Z a-z 0-9 _ . : -` (the built-in flood row uses a digest of a room id that does not fit).
375
+ - **Events, not lines.** Record what happens in your game (a mute, a kick), not every chat line: each record is a store write.
376
+ - **Counting is by distinct source.** A source is the `by` player; with no `by`, the room; with neither, the UTC day. A thousand mutes from one
377
+ player are one source. At most one row per kind, subject and source per `guards.perByWindowMs` (a day by default): the cap is a calendar bucket
378
+ (`floor(at / perByWindowMs)`), not a rolling window, so two rows a millisecond apart across a bucket edge both count, and changing the window later
379
+ re-buckets old rows. The optional `signals.accountAgeDays` hook (asked at most once a minute per player) with `guards.newAccount` makes a new account
380
+ count for a fraction of one. What this cannot stop is several real accounts that agree to signal one player: that is why a signal never acts.
381
+ - **Four feeds** (`profile.signals.feeds`, each off until set, editable in the hub: Settings, Advanced, "Signals"; a layer's `feeds` replaces the code's
382
+ wholesale): **`record`** (counts on the Person page), **`queue`** (a person who meets a threshold is taken ahead of older ordinary cases, capped, and an
383
+ overdue case still comes first), **`ladder`** (rules that add a sentence to the suggested step, or raise it one step; negative kinds only for a raise)
384
+ and **`ai`** (the counts as background for the AI read). A threshold is `kinds`, `minDistinct` (1 to 50), `windowDays` (1 to 90 and not above
385
+ `retention.signalsMs`) and an optional `minWeight`.
386
+ - **Retention.** Signal rows are kept 90 days by default (`retention.signalsMs`, never less than 14); a feed window longer than that is refused, in code
387
+ and in the hub, which reads the number from `cw.policy.get().limits.signalsMs`. A stored feed that can no longer be used (its kind is gone, or its window
388
+ is now too long) is dropped alone and reported as `dropped` on `cw.policy.get()`; the rest of the layer stays.
389
+ - **Your store needs the signal methods** (`insertSignal`, `listSignalSources`, `purgeSignals`, optional on `Store`). The SQLite store has them (migration 21,
390
+ one-way: back up the database before upgrading, since 0.1.7 and older tools cannot read a database 0.1.8 has opened); the in-memory store has them only through
391
+ `withMemorySignals(store)`. Without them `record` answers `false` and logs `chatwarden.signals_store_unsupported` once, and declaring kinds or feeds throws at
392
+ creation. The kit loads the signal code only for a store that has the methods.
393
+ - **Reads** (staff only, never to a player): `cw.signals.counts(subject, { windowDays?, kinds? })`, `kinds()`, `boosted(people)` and `forRecord(subject)`.
394
+ The `@chatwarden/http` routes read them for you and show a count only to a role that holds `history.read`.
395
+
396
+ ## The AI (levels 1 and 2)
397
+
398
+ Optional help for the moderator, `@experimental` until 0.2 and new in 0.1.7. With an adapter, the kit reads each new report after the player's
399
+ ack, in the background, and the hub shows what it found (level 1, Read); at level 2 (Recommend) the decision form opens pre-filled with a mild
400
+ suggestion that the moderator accepts or edits. It is off until you give it an adapter, and the level is then the owner's to set in the hub
401
+ (Settings > AI): 0 by default, held to the `maxLevel` you pass.
402
+
403
+ ```ts
404
+ import { createChatwarden, createFakeModerationAI } from '@chatwarden/core';
405
+ import { openStore } from '@chatwarden/store-sqlite';
406
+
407
+ // A scripted fake for a first look: it reads a report by simple rules, with no key and no network.
408
+ // A real adapter is any object with an `id` and a `read` function (the `ModerationAI` type).
409
+ const adapter = createFakeModerationAI([], { id: 'demo-fake' });
410
+
411
+ const cw = await createChatwarden({
412
+ store: openStore({ path: './chatwarden.db' }),
413
+ secret: process.env.CHATWARDEN_SECRET!,
414
+ platform,
415
+ ai: { adapter, maxLevel: 2, dailyBudgetMicros: 1_000_000 },
416
+ });
417
+ console.log(cw.ai.status()); // { available: true, level: 0, maxLevel: 2, state: 'ok', ... }
418
+ ```
419
+
420
+ - **The adapter only sends.** The kit chooses and redacts the lines, renders the prompt, checks the model's answer against the rules and
421
+ the ceilings, and stores it. Your `read(input, { signal })` sends `input.prompt` and returns `{ output, usage }`; anything it throws must
422
+ be an `AIError` (`'declined'`, `'fatal'`, `'timeout'`, `'retryable'`). `examples/ai-anthropic` is a copy-and-own adapter for Anthropic, and
423
+ `docs/adoption/moxgate.md` has the steps for turning it on.
424
+ - **It advises; it never acts.** The AI never writes a sanction, a strike, a mute or a notice: nothing under `core/src/ai` imports the modules
425
+ that do (a lint rule and a test hold that). The one-key accept never fills in a ban, an area ban or anything longer than 24 hours
426
+ (`AI_MAX_PREFILL_MS`), and a suggestion to uphold or note needs a cited line by the reported person.
427
+ - **What leaves your server.** Only the chosen lines of the report with the speakers replaced by `P1`, `P2`, ..., the reporter's reason and
428
+ note (redacted), your Community Rules and the standard. Flags, mutes and report counts are never sent, nor any id, handle, IP, hash, room or
429
+ tag. The one exception is the signal feed `feeds.ai` (`profile.signals`, off unless you set it): the counts you chose about the reported player
430
+ only are sent as one last row, a label, a number of players and a number of days, and the read records what it was shown (shown to moderators as
431
+ "Context included: N signal counts"). The prompt version is 3 for everyone, whether or not you use signals: the stable part of the prompt gained a short paragraph about context, so it changes the input hash, and after upgrading from 0.1.7 every stored read is marked stale and read again, once per open report, the first time its case is opened or when the background sweep reaches it. Those reads spend your daily call and money caps, and your provider's prompt cache starts cold. A line the word filter blocked is sent as typed unless you set `blockedLines: 'mask'`: the model needs the words to judge intent.
432
+ - **What it costs.** `dailyBudgetMicros` (default $1.00 a UTC day) is set in code and a hub cannot raise it. The owner also sets a ceiling on
433
+ calls a day (`profile.ai.dailyCalls`, default 5 000), so an adapter that reports no cost still cannot run unbounded. There are at most 30 calls
434
+ a minute and 2 at once, a hard deadline per call (`timeoutMs`) and a breaker that opens after repeated failures. At a limit, reads pause. A call that a shutdown aborts books nothing, so a restart loop around a slow provider can under-count the day's money; the call ceiling still bounds it.
435
+ - **Learning.** With `profile.ai.learn` off no example is sent and no new example text is kept, but text already stored stays until its 180 days are up or
436
+ a senior marks the case "don't teach".
437
+ - **It cannot get in the way.** A failing, slow, refusing or garbage-returning provider changes nothing else: the player's ack does not wait for
438
+ the provider, the queue and the case page answer exactly as with the AI off, and a read that fails shows nothing.
439
+ - **Your store needs the AI methods.** The SQLite store has them (it adds three tables in migration 20, which is one-way: back up the database before upgrading); the in-memory store has them only
440
+ through `withMemoryAi(store)`. A store without them leaves the AI inert: `createChatwarden` logs `chatwarden.ai_store_unsupported` once and
441
+ carries on (a bad `ai` option still throws).
442
+ - **`cw.ai`** is always there: `level()`, `status()`, `read(reportId)`, `expected(reportId)` (whether a read of that report is on its way now: the level is 1 or 2, an adapter is set up, the breaker is closed, neither daily limit is reached and its read has not ended without an answer), `readAgain(reportId, actor)`, `stats()` (the casebook counts) and `idle()`.
443
+ Without an adapter it answers as if the AI were off. The kit loads the AI code only when you pass `ai`, so a bundler can leave it out of a
444
+ browser build that never does.
445
+ - **To try it with no key**, run `examples/tiny-chat` with `CW_DEMO_AI=1`; tests use `createFakeModerationAI` and never need a network.
446
+
279
447
  ## Typing indicators
280
448
 
281
449
  Do not show a "typing..." indicator for a player who cannot chat. `cw.chat.restricted(who, { roomId, seatId })` runs the
@@ -340,13 +508,15 @@ in a browser.
340
508
  | `gate` | `(roomId, subject) => boolean`: who may chat. False refuses the line with `'gate'`. |
341
509
  | `onReport` | Told once for each stored report. It carries subject ids and the evidence: staff channels only. |
342
510
  | `onAutoRestrict` | Told when a blocked line earned an automatic timeout. The same moment is also the `auto.restricted` event. |
343
- | `retention` | How long rows are kept and how often the purge runs (every 6 hours by default), or `false` to run `purge()` yourself. Defaults: reports 90 days, strikes 30, notices 90, audit 365. Floors apply. |
511
+ | `retention` | How long rows are kept and how often the purge runs (every 6 hours by default), or `false` to run `purge()` yourself. Defaults: reports 90 days, strikes 30, notices 90, audit 365, signals 90 (`signalsMs`, never less than 14). Floors apply. |
344
512
  | `profile` | `'relaxed'`, `'standard'` (default), `'strict'`, or your own profile from `defineProfile`. |
345
513
  | `overrides` | Changes to the profile, merged onto it (`{ profanity: { mode: 'allow' } }`). A list you give replaces the preset's list. |
346
514
  | `limits` | The numbers the kit enforces: line length and rate, strikes and timeouts, report limits. Each must be a whole number above 0. |
347
515
  | `logger` | `{ warn(event, detail?) }`. Defaults to `console.warn`. It only ever receives an event name and an error class. |
348
516
  | `rules` | The numbered Community Rules, from `defineRules`. Defaults to the preset's starter set. |
349
517
  | `autoRestrictRule` | The rule number the automatic slur filter cites (default 1). Must be an active rule. |
518
+ | `ai` | `{ adapter, maxLevel?, dailyBudgetMicros?, ... }`: turns on AI reads (levels 1 and 2). Off without it. See "The AI (levels 1 and 2)" below. |
519
+ | `signals` | `{ accountAgeDays? }`: the one hook the profile cannot hold (how old a player's account is, for the new-account guard). The kinds, guards and feeds are in `profile.signals`. Needs a store with the signal methods (SQLite; `withMemorySignals(store)` for the in-memory store). `@experimental`. |
350
520
 
351
521
  Bad options throw at creation (`ProfileError`, `RangeError`), before the store is touched.
352
522
 
@@ -0,0 +1,46 @@
1
+ import type { AiOutcomeDetail, AiVerdict, SanctionKind } from '../types.js';
2
+ import type { AIRead } from './types.js';
3
+ /** A step as a person would take it: a kind and a length (null for a warning, a note or a permanent one). */
4
+ export interface StepLike {
5
+ kind: SanctionKind;
6
+ durationMs: number | null;
7
+ }
8
+ /** What the human decided about the reported person, as the server sees it. */
9
+ export interface HumanDecision {
10
+ verdict: 'upheld' | 'noted' | 'no_action' | 'bad_faith';
11
+ /** The Community Rule the human cited against the reported person, or null (a dismissal). */
12
+ rule: number | 'uncovered' | null;
13
+ /** The ids of the reported person's lines the human cited. */
14
+ lineIds: readonly string[];
15
+ /** The strongest step the human took against the reported person, or null. */
16
+ step: StepLike | null;
17
+ /** The step the ladder gives for the AI's conduct level: what the pre-fill would have been; null when there was none. */
18
+ prefill: StepLike | null;
19
+ /** How many actions the decision took on people other than the reported person (the reporter, a bystander); absent means none. */
20
+ others?: number;
21
+ /** 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}). */
22
+ oneClick: boolean;
23
+ }
24
+ /** The result: the class of agreement, the AI's verdict in the casebook's three classes, and the finer facts. */
25
+ export interface Agreement {
26
+ agreement: 'agree' | 'override' | 'none';
27
+ /** What the AI recommended, or null when no recommendation was shown (level 1, `unclear`, or no read). */
28
+ aiVerdict: AiVerdict | null;
29
+ detail: AiOutcomeDetail;
30
+ }
31
+ /**
32
+ * 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
33
+ * kind, by length (permanent last). Negative when `a` is milder than `b`, zero when equal, positive when `a` is harsher.
34
+ */
35
+ export declare function compareSteps(a: StepLike | null, b: StepLike | null): number;
36
+ /**
37
+ * Compare the AI's recommendation in `read` with `decision`. `level` is the AI level in force: below 2 the recommendation was not
38
+ * shown, so there is nothing to agree with (`none`). `upheld` and `noted` are one class (the AI wanted to act, or to record);
39
+ * `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).
40
+ * 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`).
41
+ * `detail.oneClick` is the server's verdict, not the client's claim: true only when the client said so AND the decision is an
42
+ * 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
43
+ * 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.
44
+ */
45
+ export declare function agreementOf(read: AIRead | null, decision: HumanDecision, level?: 0 | 1 | 2): Agreement;
46
+ //# sourceMappingURL=agreement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agreement.d.ts","sourceRoot":"","sources":["../../../src/ai/agreement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAKzC,6GAA6G;AAC7G,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IACxD,6FAA6F;IAC7F,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAClC,8DAA8D;IAC9D,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,8EAA8E;IAC9E,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,yHAAyH;IACzH,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB,kIAAkI;IAClI,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wKAAwK;IACxK,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,iHAAiH;AACjH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACzC,0GAA0G;IAC1G,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,eAAe,CAAC;CACzB;AAUD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAM,CAQ3E;AAeD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,GAAE,CAAC,GAAG,CAAC,GAAG,CAAK,GAAG,SAAS,CAwBzG"}
@@ -0,0 +1,71 @@
1
+ const KIND_RANK = { note: 1, warning: 2, chat: 3, area: 4, ban: 5 };
2
+ /** How long a step lasts for ordering: no length for a note or warning, and a permanent restriction or ban beyond any length. */
3
+ function lengthOf(s) {
4
+ if (s.kind === 'note' || s.kind === 'warning')
5
+ return 0;
6
+ return s.durationMs === null ? Number.POSITIVE_INFINITY : s.durationMs;
7
+ }
8
+ /**
9
+ * 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
10
+ * kind, by length (permanent last). Negative when `a` is milder than `b`, zero when equal, positive when `a` is harsher.
11
+ */
12
+ export function compareSteps(a, b) {
13
+ const kindA = a === null ? 0 : (KIND_RANK[a.kind] ?? 0);
14
+ const kindB = b === null ? 0 : (KIND_RANK[b.kind] ?? 0);
15
+ if (kindA !== kindB)
16
+ return kindA < kindB ? -1 : 1;
17
+ if (a === null || b === null)
18
+ return 0;
19
+ const x = lengthOf(a);
20
+ const y = lengthOf(b);
21
+ return x < y ? -1 : x > y ? 1 : 0;
22
+ }
23
+ const NO_DETAIL = { verdict: false, rule: false, lines: 0, outcome: 'none', oneClick: false };
24
+ /**
25
+ * 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
26
+ * still their one click), or both without a step (a dismissal accepted as one).
27
+ */
28
+ function stepAccepted(step, prefill) {
29
+ if (step === null || prefill === null)
30
+ return step === null && prefill === null;
31
+ if (step.kind !== prefill.kind)
32
+ return false;
33
+ if (step.durationMs === prefill.durationMs)
34
+ return true;
35
+ return step.durationMs !== null && prefill.durationMs !== null && step.durationMs <= prefill.durationMs;
36
+ }
37
+ /**
38
+ * Compare the AI's recommendation in `read` with `decision`. `level` is the AI level in force: below 2 the recommendation was not
39
+ * shown, so there is nothing to agree with (`none`). `upheld` and `noted` are one class (the AI wanted to act, or to record);
40
+ * `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).
41
+ * 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`).
42
+ * `detail.oneClick` is the server's verdict, not the client's claim: true only when the client said so AND the decision is an
43
+ * 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
44
+ * 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.
45
+ */
46
+ export function agreementOf(read, decision, level = 2) {
47
+ const rec = read?.recommendation ?? null;
48
+ if (level < 2 || rec === null || rec.verdict === 'unclear') {
49
+ return { agreement: 'none', aiVerdict: null, detail: { ...NO_DETAIL } };
50
+ }
51
+ const aiVerdict = rec.verdict;
52
+ const aiActs = aiVerdict === 'upheld' || aiVerdict === 'noted';
53
+ const humanActs = decision.verdict === 'upheld' || decision.verdict === 'noted';
54
+ const same = decision.verdict !== 'bad_faith' && aiActs === humanActs;
55
+ const cited = new Set(rec.evidence);
56
+ const lines = new Set(decision.lineIds.filter((id) => cited.has(id))).size;
57
+ const cmp = compareSteps(decision.step, decision.prefill);
58
+ const ruleMatches = aiVerdict === 'no_action' || rec.rule === decision.rule;
59
+ return {
60
+ agreement: same ? 'agree' : 'override',
61
+ aiVerdict,
62
+ detail: {
63
+ verdict: same,
64
+ rule: ruleMatches,
65
+ lines,
66
+ outcome: cmp === 0 ? 'same' : cmp < 0 ? 'milder' : 'harsher',
67
+ oneClick: decision.oneClick && same && rec.verdict === decision.verdict && ruleMatches && (decision.others ?? 0) === 0 && stepAccepted(decision.step, decision.prefill),
68
+ },
69
+ };
70
+ }
71
+ //# sourceMappingURL=agreement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agreement.js","sourceRoot":"","sources":["../../../src/ai/agreement.ts"],"names":[],"mappings":"AAqCA,MAAM,SAAS,GAAiC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAElG,iIAAiI;AACjI,SAAS,QAAQ,CAAC,CAAW;IAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IACxD,OAAO,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,CAAkB,EAAE,CAAkB;IACjE,MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,KAAK,GAAG,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QAAQ,CAAC,CAAC,CAAC,SAAS;YAC5D,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,IAAI,IAAI,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,IAAI,WAAW,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;SACxK;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ /** Consecutive failures that open the breaker. */
2
+ export declare const BREAKER_THRESHOLD = 5;
3
+ /** How long an open breaker refuses calls before one probe is let through. */
4
+ export declare const BREAKER_OPEN_MS: number;
5
+ /** Whether a call may be made now: freely, as the one probe, or not at all. */
6
+ export type BreakerGate = 'go' | 'probe' | 'no';
7
+ /** What the hub shows: `closed` is working, `open` and `half_open` are "unavailable". */
8
+ export type BreakerState = 'closed' | 'open' | 'half_open';
9
+ export declare class Breaker {
10
+ private failures;
11
+ private openUntil;
12
+ private probing;
13
+ private readonly clock;
14
+ constructor(clock: {
15
+ now(): number;
16
+ });
17
+ /** Ask to make a call. A `probe` is handed out once; report its end with {@link success}, {@link failure} or {@link release}. */
18
+ gate(): BreakerGate;
19
+ /** Whether a call could go out now: closed, or half-open with the probe free. Takes nothing (see {@link gate}). */
20
+ available(): boolean;
21
+ state(): BreakerState;
22
+ /** When an open breaker lets the probe through (epoch ms), or null when closed. */
23
+ reopensAt(): number | null;
24
+ /** A call produced an answer (even a refusal or an unusable one). Closes the breaker. */
25
+ success(): void;
26
+ /** A call failed. `fatal` opens at once; so does a failed probe and the fifth failure in a row. */
27
+ failure(fatal?: boolean): void;
28
+ /** A probe was handed out but no call came of it (for example the budget stopped it): let the next ask be the probe. */
29
+ release(): void;
30
+ }
31
+ //# sourceMappingURL=breaker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breaker.d.ts","sourceRoot":"","sources":["../../../src/ai/breaker.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,8EAA8E;AAC9E,eAAO,MAAM,eAAe,QAAa,CAAC;AAE1C,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAEhD,yFAAyF;AACzF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE3D,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;gBAE9B,KAAK,EAAE;QAAE,GAAG,IAAI,MAAM,CAAA;KAAE;IAIpC,iIAAiI;IACjI,IAAI,IAAI,WAAW;IAQnB,mHAAmH;IACnH,SAAS,IAAI,OAAO;IAKpB,KAAK,IAAI,YAAY;IAKrB,mFAAmF;IACnF,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B,yFAAyF;IACzF,OAAO,IAAI,IAAI;IAMf,mGAAmG;IACnG,OAAO,CAAC,KAAK,UAAQ,GAAG,IAAI;IAS5B,wHAAwH;IACxH,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,62 @@
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
+ /** Consecutive failures that open the breaker. */
5
+ export const BREAKER_THRESHOLD = 5;
6
+ /** How long an open breaker refuses calls before one probe is let through. */
7
+ export const BREAKER_OPEN_MS = 5 * 60_000;
8
+ export class Breaker {
9
+ failures = 0;
10
+ openUntil = null;
11
+ probing = false;
12
+ clock;
13
+ constructor(clock) {
14
+ this.clock = clock;
15
+ }
16
+ /** Ask to make a call. A `probe` is handed out once; report its end with {@link success}, {@link failure} or {@link release}. */
17
+ gate() {
18
+ if (this.openUntil === null)
19
+ return 'go';
20
+ if (this.clock.now() < this.openUntil)
21
+ return 'no';
22
+ if (this.probing)
23
+ return 'no';
24
+ this.probing = true;
25
+ return 'probe';
26
+ }
27
+ /** Whether a call could go out now: closed, or half-open with the probe free. Takes nothing (see {@link gate}). */
28
+ available() {
29
+ if (this.openUntil === null)
30
+ return true;
31
+ return this.clock.now() >= this.openUntil && !this.probing;
32
+ }
33
+ state() {
34
+ if (this.openUntil === null)
35
+ return 'closed';
36
+ return this.clock.now() < this.openUntil ? 'open' : 'half_open';
37
+ }
38
+ /** When an open breaker lets the probe through (epoch ms), or null when closed. */
39
+ reopensAt() {
40
+ return this.openUntil;
41
+ }
42
+ /** A call produced an answer (even a refusal or an unusable one). Closes the breaker. */
43
+ success() {
44
+ this.failures = 0;
45
+ this.openUntil = null;
46
+ this.probing = false;
47
+ }
48
+ /** A call failed. `fatal` opens at once; so does a failed probe and the fifth failure in a row. */
49
+ failure(fatal = false) {
50
+ this.failures += 1;
51
+ if (fatal || this.probing || this.failures >= BREAKER_THRESHOLD) {
52
+ this.openUntil = this.clock.now() + BREAKER_OPEN_MS;
53
+ this.failures = 0;
54
+ }
55
+ this.probing = false;
56
+ }
57
+ /** A probe was handed out but no call came of it (for example the budget stopped it): let the next ask be the probe. */
58
+ release() {
59
+ this.probing = false;
60
+ }
61
+ }
62
+ //# sourceMappingURL=breaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breaker.js","sourceRoot":"","sources":["../../../src/ai/breaker.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,qIAAqI;AACrI,qIAAqI;AAErI,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC;AAQ1C,MAAM,OAAO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AAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACnB,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,IAAI,iBAAiB,EAAE,CAAC;YAChE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC;YACpD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,wHAAwH;IACxH,OAAO;QACL,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ /** Epoch ms of 00:00 UTC on the day that holds `ms`. */
2
+ export declare function startOfUtcDay(ms: number): number;
3
+ /** Epoch ms of the next 00:00 UTC after `ms`: when a day's cap resets. */
4
+ export declare function nextUtcMidnight(ms: number): number;
5
+ /** The UTC day as `YYYY-MM-DD`. */
6
+ export declare function utcDayLabel(ms: number): string;
7
+ /**
8
+ * At most `limit` calls in any `windowMs` (the per-minute cap). In-memory: it guards a burst in this process; the daily spend cap is
9
+ * what the store shares.
10
+ */
11
+ export declare class CallWindow {
12
+ private readonly at;
13
+ private readonly limit;
14
+ private readonly windowMs;
15
+ constructor(limit: number, windowMs?: number);
16
+ /** Take a slot at `now`; false (nothing taken) when the window is full. */
17
+ tryTake(now: number): boolean;
18
+ /** Whether a slot is free at `now`, taking none. */
19
+ peek(now: number): boolean;
20
+ /** When a slot is free: `now` if one is, else the moment the oldest call leaves the window. */
21
+ nextFree(now: number): number;
22
+ /** Give back the slot taken at `now` (the call was not made after all). */
23
+ giveBack(now: number): void;
24
+ private trim;
25
+ }
26
+ //# sourceMappingURL=budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../../../src/ai/budget.ts"],"names":[],"mappings":"AAKA,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;IAEnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAS;IAK5C,2EAA2E;IAC3E,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAO7B,oDAAoD;IACpD,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAK1B,+FAA+F;IAC/F,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK7B,2EAA2E;IAC3E,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK3B,OAAO,CAAC,IAAI;CAGb"}
@@ -0,0 +1,57 @@
1
+ // The spend cap and the call-rate cap (design section 4). The cap is over the UTC day and computed from the stored spend, so it
2
+ // survives a restart and is shared by every process on the store; the helpers here only name the day.
3
+ const DAY_MS = 24 * 3_600_000;
4
+ /** Epoch ms of 00:00 UTC on the day that holds `ms`. */
5
+ export function startOfUtcDay(ms) {
6
+ return Math.floor(ms / DAY_MS) * DAY_MS;
7
+ }
8
+ /** Epoch ms of the next 00:00 UTC after `ms`: when a day's cap resets. */
9
+ export function nextUtcMidnight(ms) {
10
+ return startOfUtcDay(ms) + DAY_MS;
11
+ }
12
+ /** The UTC day as `YYYY-MM-DD`. */
13
+ export function utcDayLabel(ms) {
14
+ return new Date(startOfUtcDay(ms)).toISOString().slice(0, 10);
15
+ }
16
+ /**
17
+ * At most `limit` calls in any `windowMs` (the per-minute cap). In-memory: it guards a burst in this process; the daily spend cap is
18
+ * what the store shares.
19
+ */
20
+ export class CallWindow {
21
+ at = [];
22
+ limit;
23
+ windowMs;
24
+ constructor(limit, windowMs = 60_000) {
25
+ this.limit = limit;
26
+ this.windowMs = windowMs;
27
+ }
28
+ /** Take a slot at `now`; false (nothing taken) when the window is full. */
29
+ tryTake(now) {
30
+ this.trim(now);
31
+ if (this.at.length >= this.limit)
32
+ return false;
33
+ this.at.push(now);
34
+ return true;
35
+ }
36
+ /** Whether a slot is free at `now`, taking none. */
37
+ peek(now) {
38
+ this.trim(now);
39
+ return this.at.length < this.limit;
40
+ }
41
+ /** When a slot is free: `now` if one is, else the moment the oldest call leaves the window. */
42
+ nextFree(now) {
43
+ this.trim(now);
44
+ return this.at.length < this.limit ? now : this.at[0] + this.windowMs;
45
+ }
46
+ /** Give back the slot taken at `now` (the call was not made after all). */
47
+ giveBack(now) {
48
+ const i = this.at.lastIndexOf(now);
49
+ if (i >= 0)
50
+ this.at.splice(i, 1);
51
+ }
52
+ trim(now) {
53
+ while (this.at.length > 0 && this.at[0] <= now - this.windowMs)
54
+ this.at.shift();
55
+ }
56
+ }
57
+ //# sourceMappingURL=budget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget.js","sourceRoot":"","sources":["../../../src/ai/budget.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,sGAAsG;AAEtG,MAAM,MAAM,GAAG,EAAE,GAAG,SAAS,CAAC;AAE9B,wDAAwD;AACxD,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC1C,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,aAAa,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;AACpC,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,IAAI,IAAI,CAAC,aAAa,CAA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AAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAEO,IAAI,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,IAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAY,IAAI,GAAG,GAAG,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAC9F,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ import type { DocumentPolicy } from '../documents.js';
2
+ import type { ReportReason } from '../reporting.js';
3
+ import type { ReportRecord } from '../types.js';
4
+ import type { ChosenLines } from './lines.js';
5
+ import type { AIExampleInput, AIReadInput, AISignal } from './types.js';
6
+ /** A report ready to be read (or to be compared with a stored read). */
7
+ export interface Prepared {
8
+ /** The input without casebook examples: what the hash is of. */
9
+ input: AIReadInput;
10
+ chosen: ChosenLines;
11
+ /** `inputHash(input, adapterId)`. */
12
+ hash: string;
13
+ /** A line or the note looks like an instruction to the AI (the tripwire). */
14
+ injection: boolean;
15
+ /** Every line ref that is in the prompt. */
16
+ refs: ReadonlySet<string>;
17
+ /** The numbers of the rules that were active when the prompt was built. */
18
+ activeRules: ReadonlySet<number>;
19
+ /** The refs of the lines the reported person wrote. */
20
+ ownRefs: ReadonlySet<string>;
21
+ /** The real line id behind each ref. Never handed to an adapter. */
22
+ idOf: ReadonlyMap<string, string>;
23
+ /** The real ids of the lines the reported person wrote (among the chosen). */
24
+ ownLineIds: ReadonlySet<string>;
25
+ /** The same input with casebook examples and the signal counts about P1 in it (at most two examples are used). The hash does not change. */
26
+ build(examples: readonly AIExampleInput[], signals?: readonly AISignal[]): AIReadInput;
27
+ }
28
+ export interface PrepareArgs {
29
+ report: ReportRecord;
30
+ policy: DocumentPolicy;
31
+ reasons: readonly ReportReason[];
32
+ adapterId: string;
33
+ /** `blockedLines: 'mask'`: send a line the filter touched masked, not raw. */
34
+ mask: boolean;
35
+ }
36
+ export declare function prepare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