@chatwarden/core 0.1.8 → 0.1.9
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.
- package/README.md +184 -5
- package/dist/src/ai/case.d.ts +2 -1
- package/dist/src/ai/case.d.ts.map +1 -1
- package/dist/src/ai/case.js +1 -1
- package/dist/src/ai/case.js.map +1 -1
- package/dist/src/ai/hash.d.ts +1 -1
- package/dist/src/ai/hash.js +3 -3
- package/dist/src/ai/hash.js.map +1 -1
- package/dist/src/ai/prompt.d.ts +8 -1
- package/dist/src/ai/prompt.d.ts.map +1 -1
- package/dist/src/ai/prompt.js +20 -1
- package/dist/src/ai/prompt.js.map +1 -1
- package/dist/src/ai/service.d.ts +16 -5
- package/dist/src/ai/service.d.ts.map +1 -1
- package/dist/src/ai/service.js +12 -7
- package/dist/src/ai/service.js.map +1 -1
- package/dist/src/ai/types.d.ts +17 -2
- package/dist/src/ai/types.d.ts.map +1 -1
- package/dist/src/ai/types.js +3 -2
- package/dist/src/ai/types.js.map +1 -1
- package/dist/src/ai/worker.d.ts +5 -0
- package/dist/src/ai/worker.d.ts.map +1 -1
- package/dist/src/ai/worker.js +9 -2
- package/dist/src/ai/worker.js.map +1 -1
- package/dist/src/appealService.d.ts +105 -0
- package/dist/src/appealService.d.ts.map +1 -0
- package/dist/src/appealService.js +548 -0
- package/dist/src/appealService.js.map +1 -0
- package/dist/src/appeals.d.ts +194 -0
- package/dist/src/appeals.d.ts.map +1 -0
- package/dist/src/appeals.js +107 -0
- package/dist/src/appeals.js.map +1 -0
- package/dist/src/audit.d.ts +7 -3
- package/dist/src/audit.d.ts.map +1 -1
- package/dist/src/audit.js +18 -3
- package/dist/src/audit.js.map +1 -1
- package/dist/src/chatwarden.d.ts +129 -9
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +94 -19
- package/dist/src/chatwarden.js.map +1 -1
- package/dist/src/decide.d.ts +2 -0
- package/dist/src/decide.d.ts.map +1 -1
- package/dist/src/decide.js +12 -7
- package/dist/src/decide.js.map +1 -1
- package/dist/src/documents.d.ts +1 -1
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +3 -1
- package/dist/src/documents.js.map +1 -1
- package/dist/src/events.d.ts +38 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +3 -0
- package/dist/src/events.js.map +1 -1
- package/dist/src/index.d.ts +9 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/nameService.d.ts +90 -0
- package/dist/src/nameService.d.ts.map +1 -0
- package/dist/src/nameService.js +224 -0
- package/dist/src/nameService.js.map +1 -0
- package/dist/src/names.d.ts +68 -0
- package/dist/src/names.d.ts.map +1 -0
- package/dist/src/names.js +87 -0
- package/dist/src/names.js.map +1 -0
- package/dist/src/notices.d.ts +53 -5
- package/dist/src/notices.d.ts.map +1 -1
- package/dist/src/notices.js +93 -8
- package/dist/src/notices.js.map +1 -1
- package/dist/src/policy.d.ts +9 -0
- package/dist/src/policy.d.ts.map +1 -1
- package/dist/src/policy.js +20 -2
- package/dist/src/policy.js.map +1 -1
- package/dist/src/profile.d.ts +23 -1
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +14 -2
- package/dist/src/profile.js.map +1 -1
- package/dist/src/retention.d.ts +31 -1
- package/dist/src/retention.d.ts.map +1 -1
- package/dist/src/retention.js +41 -3
- package/dist/src/retention.js.map +1 -1
- package/dist/src/sanctions.d.ts +29 -1
- package/dist/src/sanctions.d.ts.map +1 -1
- package/dist/src/sanctions.js +52 -9
- package/dist/src/sanctions.js.map +1 -1
- package/dist/src/staffViews.d.ts +18 -0
- package/dist/src/staffViews.d.ts.map +1 -1
- package/dist/src/staffViews.js +14 -0
- package/dist/src/staffViews.js.map +1 -1
- package/dist/src/types.d.ts +198 -6
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -2
- package/src/ai/case.ts +4 -2
- package/src/ai/hash.ts +3 -3
- package/src/ai/prompt.ts +23 -1
- package/src/ai/service.ts +21 -12
- package/src/ai/types.ts +14 -2
- package/src/ai/worker.ts +10 -2
- package/src/appealService.ts +584 -0
- package/src/appeals.ts +256 -0
- package/src/audit.ts +18 -3
- package/src/chatwarden.ts +199 -21
- package/src/decide.ts +13 -7
- package/src/documents.ts +6 -3
- package/src/events.ts +23 -1
- package/src/index.ts +12 -1
- package/src/nameService.ts +255 -0
- package/src/names.ts +121 -0
- package/src/notices.ts +112 -14
- package/src/policy.ts +20 -3
- package/src/profile.ts +34 -2
- package/src/retention.ts +63 -3
- package/src/sanctions.ts +72 -9
- package/src/staffViews.ts +30 -0
- package/src/types.ts +210 -7
package/src/staffViews.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { parseRuleRef } from './rules.js';
|
|
|
9
9
|
import type { RuleRef } from './rules.js';
|
|
10
10
|
import { SANCTION_SOURCES } from './sanctions.js';
|
|
11
11
|
import { b64urlDecode, b64urlEncode } from './staffReports.js';
|
|
12
|
+
import type { NameReason } from './names.js';
|
|
12
13
|
import type { SubjectIndex } from './subjects.js';
|
|
13
14
|
import type { SanctionKind, SanctionRow, Source, Store, SubjectId } from './types.js';
|
|
14
15
|
|
|
@@ -290,6 +291,8 @@ export function reporterRecord(
|
|
|
290
291
|
|
|
291
292
|
/** The most blocked messages one call lists. */
|
|
292
293
|
export const BLOCKED_MAX = 500;
|
|
294
|
+
/** The most kept blocked names `blocked.names` lists: what the store will return in one read (a store clamps its limit to 200). */
|
|
295
|
+
export const BLOCKED_NAMES_MAX = 200;
|
|
293
296
|
|
|
294
297
|
/** The look-back windows of the blocked list, in days. */
|
|
295
298
|
export const BLOCKED_DAYS = [1, 7, 30] as const;
|
|
@@ -336,3 +339,30 @@ export function blockedCountsByTerm(store: Store, days: unknown, now: number): R
|
|
|
336
339
|
for (const r of store.countStrikesByTerm(sinceOf(days, now))) out[r.termId] = r.count;
|
|
337
340
|
return out;
|
|
338
341
|
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* One kept blocked name (`names.keepBlocked`): the name as it was typed, the term the matcher reported (null for a profanity hit), why it was
|
|
345
|
+
* refused, and the person when the caller was found (a staff ref; null for a caller the kit did not hold). Carries a name and a subject id: staff
|
|
346
|
+
* channels only, never send to a player.
|
|
347
|
+
*/
|
|
348
|
+
export interface BlockedNameItem {
|
|
349
|
+
id: string;
|
|
350
|
+
at: number;
|
|
351
|
+
person: SubjectId | null;
|
|
352
|
+
name: string;
|
|
353
|
+
termId: string | null;
|
|
354
|
+
reason: NameReason;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** The kept blocked names of the last `days` days (1, 7 or 30; `RangeError` otherwise), newest first, at most {@link BLOCKED_NAMES_MAX}. Empty for a store that keeps none. */
|
|
358
|
+
export function blockedNameItems(store: Store, subjects: SubjectIndex, days: unknown, now: number): BlockedNameItem[] {
|
|
359
|
+
const since = sinceOf(days, now);
|
|
360
|
+
return (store.listBlockedNames?.(since, BLOCKED_NAMES_MAX) ?? []).map((r) => ({
|
|
361
|
+
id: r.id,
|
|
362
|
+
at: r.at,
|
|
363
|
+
person: r.subject === null ? null : subjects.canonical(r.subject),
|
|
364
|
+
name: r.name,
|
|
365
|
+
termId: r.termId,
|
|
366
|
+
reason: r.reason,
|
|
367
|
+
}));
|
|
368
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// their own sections below.
|
|
3
3
|
|
|
4
4
|
import type { AIExample, AIRead, AISignal } from './ai/types.js';
|
|
5
|
+
import type { AppealStatus } from './appeals.js';
|
|
5
6
|
import type { AuditListQuery, AuditRow } from './audit.js';
|
|
7
|
+
import type { NameReason } from './names.js';
|
|
6
8
|
import type { PolicyLayer } from './profile.js';
|
|
7
9
|
import type { RuleRef } from './rules.js';
|
|
8
10
|
|
|
@@ -182,6 +184,13 @@ export interface SanctionRow {
|
|
|
182
184
|
*/
|
|
183
185
|
revokedBy?: string | null;
|
|
184
186
|
revokeReason?: string | null;
|
|
187
|
+
/**
|
|
188
|
+
* The report whose decision made this sanction (a moderator decision from 0.1.9 stores the decided report's id), so a granted appeal can
|
|
189
|
+
* mark that decision reversed. Absent or null for a sanction that did not come from a report decision (an automatic timeout, a direct
|
|
190
|
+
* `sanctions.apply`, and every row written before 0.1.9 that could not be linked). Optional so a store written for an older kit still
|
|
191
|
+
* type-checks; read an absent value as null. Private.
|
|
192
|
+
*/
|
|
193
|
+
reportId?: string | null;
|
|
185
194
|
}
|
|
186
195
|
|
|
187
196
|
/**
|
|
@@ -340,6 +349,52 @@ export interface SignalRow {
|
|
|
340
349
|
capBucket: number;
|
|
341
350
|
}
|
|
342
351
|
|
|
352
|
+
/**
|
|
353
|
+
* One appeal, as the store keeps it (appeals inbox, design 4.7). `statement` is the player's own text, capped at APPEAL_STATEMENT_MAX
|
|
354
|
+
* characters: the only new player free text, kept here and nowhere else, nulled by retention. Private: a player sees `PlayerAppeal`, never
|
|
355
|
+
* this. `rule` is the sanction's rule as TEXT (`'1'`.. or `'uncovered'`), like a sanction row.
|
|
356
|
+
* @experimental
|
|
357
|
+
*/
|
|
358
|
+
export interface AppealRow {
|
|
359
|
+
/** Random, never derived. */
|
|
360
|
+
id: string;
|
|
361
|
+
/** The canonical subject at filing time. */
|
|
362
|
+
subject: SubjectId;
|
|
363
|
+
/** The sanction group appealed; one appeal per group. */
|
|
364
|
+
groupId: string;
|
|
365
|
+
/** The notice the player filed it from. */
|
|
366
|
+
noticeId: string;
|
|
367
|
+
/** The report whose decision made the sanction, when known (so a granted appeal can mark that decision reversed). */
|
|
368
|
+
reportId: string | null;
|
|
369
|
+
rule: string | null;
|
|
370
|
+
kind: SanctionKind;
|
|
371
|
+
/** The player's statement; null once retention cleared it (or it was cleared at decision). */
|
|
372
|
+
statement: string | null;
|
|
373
|
+
status: AppealStatus;
|
|
374
|
+
createdAt: number;
|
|
375
|
+
decidedAt: number | null;
|
|
376
|
+
/** The staff ref that decided it (or revoked the sanction, for a moot one). */
|
|
377
|
+
decidedBy: string | null;
|
|
378
|
+
/** Private; never shown to the player. */
|
|
379
|
+
decisionReason: string | null;
|
|
380
|
+
/** The group written in place of a reduced sanction. */
|
|
381
|
+
replacementGroupId: string | null;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* One blocked name kept as evidence (only when `names.keepBlocked` is on). `subject` is null when the check could not tie the name to a
|
|
386
|
+
* person; `termId` is the matcher's term id for a `name_not_allowed` hit and null for `name_profane`. Private staff data on a short clock.
|
|
387
|
+
* @experimental
|
|
388
|
+
*/
|
|
389
|
+
export interface BlockedNameRow {
|
|
390
|
+
id: string;
|
|
391
|
+
subject: SubjectId | null;
|
|
392
|
+
name: string;
|
|
393
|
+
termId: string | null;
|
|
394
|
+
reason: NameReason;
|
|
395
|
+
at: number;
|
|
396
|
+
}
|
|
397
|
+
|
|
343
398
|
/**
|
|
344
399
|
* What `listSignalSources` answers: one row per source of a kind about a subject. Rows are bounded by distinct sources, not by volume.
|
|
345
400
|
* @experimental
|
|
@@ -408,14 +463,21 @@ export interface AiOutcomeInsert {
|
|
|
408
463
|
|
|
409
464
|
/** A stored outcome: what was inserted, and the two marks a later action sets. */
|
|
410
465
|
export interface AiOutcomeRow extends AiOutcomeInsert {
|
|
411
|
-
/** Set by a granted appeal
|
|
466
|
+
/** Set by a granted appeal. Excludes the row from standard examples; drops its example text unless the row is `corrective`. */
|
|
412
467
|
reversed: boolean;
|
|
468
|
+
/**
|
|
469
|
+
* Set by a REVOKED appeal (a second moderator found the decision wrong): the example text is kept and teaches the opposite sign, and the
|
|
470
|
+
* row counts as an AI false positive when the AI had recommended action. A reduced appeal sets `reversed` only. Never cleared.
|
|
471
|
+
*/
|
|
472
|
+
corrective: boolean;
|
|
413
473
|
/** A senior's mark. Excludes the row from examples. */
|
|
414
474
|
dontTeach: boolean;
|
|
415
475
|
}
|
|
416
476
|
|
|
417
477
|
/** One teachable casebook example, newest first from {@link Store.aiExamples}. The human's final decision is the label. */
|
|
418
478
|
export interface AiExampleRow {
|
|
479
|
+
/** `'corrective'` for a decision a granted (revoked) appeal found wrong; absent for an ordinary example. */
|
|
480
|
+
kind?: 'corrective';
|
|
419
481
|
reportId: string;
|
|
420
482
|
decidedAt: number;
|
|
421
483
|
agreement: 'agree' | 'override';
|
|
@@ -709,8 +771,21 @@ export interface ReportActivity {
|
|
|
709
771
|
// Notices (storage shape)
|
|
710
772
|
// ---------------------------------------------------------------------------
|
|
711
773
|
|
|
712
|
-
/**
|
|
713
|
-
|
|
774
|
+
/**
|
|
775
|
+
* What a player notice is about: a sanction of that kind, the outcome of a report the player filed, or one of four messages (a rename
|
|
776
|
+
* is required, an appeal was upheld, reduced or revoked). The messages are not sanctions: they have no group, no end and no excerpt,
|
|
777
|
+
* never appear on "My record" and never need an acknowledgement.
|
|
778
|
+
*/
|
|
779
|
+
export type NoticeKind =
|
|
780
|
+
| 'warning'
|
|
781
|
+
| 'chat'
|
|
782
|
+
| 'area'
|
|
783
|
+
| 'ban'
|
|
784
|
+
| 'report_outcome'
|
|
785
|
+
| 'rename_required'
|
|
786
|
+
| 'appeal_upheld'
|
|
787
|
+
| 'appeal_reduced'
|
|
788
|
+
| 'appeal_revoked';
|
|
714
789
|
|
|
715
790
|
/**
|
|
716
791
|
* One stored player notice. `subject` is the CANONICAL subject at write time (a later merge is resolved at query
|
|
@@ -722,7 +797,7 @@ export interface NoticeRow {
|
|
|
722
797
|
/** Random, never derived. */
|
|
723
798
|
id: string;
|
|
724
799
|
subject: SubjectId;
|
|
725
|
-
/** The sanction group this notice is about; null for a report outcome. */
|
|
800
|
+
/** The sanction group this notice is about; null for a report outcome and for the four message kinds. */
|
|
726
801
|
groupId: string | null;
|
|
727
802
|
kind: NoticeKind;
|
|
728
803
|
rule: string | null;
|
|
@@ -1164,14 +1239,17 @@ export interface Store {
|
|
|
1164
1239
|
|
|
1165
1240
|
/**
|
|
1166
1241
|
* 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
|
|
1167
|
-
* row can never teach, so its chat text goes now
|
|
1242
|
+
* row can never teach, so its chat text goes now, EXCEPT a `corrective` one (a revoked appeal), which keeps its text to teach the opposite
|
|
1243
|
+
* sign (a `dontTeach` mark still drops it). False for an unknown report. Moves the change token when the report has an outcome.
|
|
1168
1244
|
*/
|
|
1169
|
-
markAiOutcome?(reportId: string, patch: { reversed?: true; dontTeach?: true }): boolean;
|
|
1245
|
+
markAiOutcome?(reportId: string, patch: { reversed?: true; dontTeach?: true; corrective?: true }): boolean;
|
|
1170
1246
|
|
|
1171
1247
|
/**
|
|
1172
1248
|
* OPTIONAL. Teachable examples with this human rule (`'3'`, `'uncovered'`) and conduct level, decided at or after `since`, newest
|
|
1173
1249
|
* first (`decidedAt` descending, then `reportId` descending), at most `limit`. Teachable: an example is
|
|
1174
1250
|
* stored, the AI recommended something (`agree` or `override`, not `none`), and the row is not `reversed`, `dontTeach` or `badFaith`.
|
|
1251
|
+
* Besides these the answer may hold ONE corrective row (`kind: 'corrective'`: still has its example, not `dontTeach` or `badFaith`) of the
|
|
1252
|
+
* same rule and level, the newest; it comes after the ordinary rows are cut to `limit` and is not counted by `aiTeachableCount`.
|
|
1175
1253
|
* `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
|
|
1176
1254
|
* examples).
|
|
1177
1255
|
*/
|
|
@@ -1213,6 +1291,113 @@ export interface Store {
|
|
|
1213
1291
|
/** OPTIONAL. Delete rows with `at < before` (a row exactly on the line is kept); returns how many. */
|
|
1214
1292
|
purgeSignals?(before: number): number;
|
|
1215
1293
|
|
|
1294
|
+
// Appeals (appeals inbox, design 4.7). OPTIONAL: a store without them cannot keep appeals, and `createChatwarden` refuses a profile with
|
|
1295
|
+
// `appeals.enabled` for one. SYNCHRONOUS on purpose (like claims and notices); they run inside `transaction`. Every insert, decide and moot
|
|
1296
|
+
// moves the change token. Only `loadAppeal` and `listAppeals` return a statement (staff reads); `AppealRow` is private and never reaches
|
|
1297
|
+
// a player.
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* OPTIONAL. Insert one appeal as ONE atomic statement: false, and nothing written, when an appeal for the group already exists (one
|
|
1301
|
+
* appeal per sanction for its lifetime, whatever its status) or the id is taken. True when a row was written.
|
|
1302
|
+
*/
|
|
1303
|
+
insertAppeal?(row: AppealRow): boolean;
|
|
1304
|
+
|
|
1305
|
+
/** OPTIONAL. One appeal by id, a copy, or null. A `moot` one is returned too. */
|
|
1306
|
+
loadAppeal?(id: string): AppealRow | null;
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* OPTIONAL. Appeals oldest first (`createdAt` ascending, then `id`): `open` is the ones waiting, `decided` the upheld, reduced and
|
|
1310
|
+
* revoked ones, `all` (the default) both. A `moot` appeal (nobody ruled on it) is never listed. `after` is the keyset cursor: the
|
|
1311
|
+
* `createdAt` and `id` of the last row of the previous page, and the row it names is not repeated. `limit` is floored and clamped to
|
|
1312
|
+
* 1..200. Returns copies.
|
|
1313
|
+
*/
|
|
1314
|
+
listAppeals?(q: { status?: 'open' | 'decided' | 'all'; limit: number; after?: { createdAt: number; id: string } }): AppealRow[];
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* OPTIONAL. How many appeals these subjects (a person's canonical id and its aliases) filed at or after `since`, whatever their status
|
|
1318
|
+
* (a moot or decided one still counts against the weekly cap), and the oldest `createdAt` among them. None: `{ count: 0, oldestAt: null }`.
|
|
1319
|
+
*/
|
|
1320
|
+
countAppealsBy?(subjects: readonly SubjectId[], since: number): { count: number; oldestAt: number | null };
|
|
1321
|
+
|
|
1322
|
+
/** OPTIONAL. How many appeals are `open`. */
|
|
1323
|
+
countOpenAppeals?(): number;
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* OPTIONAL. These subjects' (a person's canonical id and aliases) appeals, newest first (`createdAt` descending, then `id` descending),
|
|
1327
|
+
* up to `limit` (floored, clamped to 1..200); a `moot` appeal is not listed. Returns copies. For "my appeals" on the player side.
|
|
1328
|
+
*/
|
|
1329
|
+
listAppealsBy?(subjects: readonly SubjectId[], limit: number): AppealRow[];
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* OPTIONAL. Decide an appeal, ONLY from `open`, as ONE atomic statement: false, and nothing changed, for an unknown id or an appeal that
|
|
1333
|
+
* is decided or moot. True when it moved. `clearStatement` also nulls the statement (retention with `appealStatementsMs` at 0).
|
|
1334
|
+
*/
|
|
1335
|
+
decideAppeal?(
|
|
1336
|
+
id: string,
|
|
1337
|
+
patch: { status: 'upheld' | 'reduced' | 'revoked'; at: number; by: string; reason: string; replacementGroupId: string | null; clearStatement?: boolean },
|
|
1338
|
+
): boolean;
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* OPTIONAL. The sanction group was revoked by someone else: move its appeal, if still `open`, to `moot` (`decidedAt` and `decidedBy`
|
|
1342
|
+
* set, no reason). Returns how many moved (0 or 1); a decided or moot appeal is untouched.
|
|
1343
|
+
*/
|
|
1344
|
+
closeAppealsForGroup?(groupId: string, by: string, at: number, clearStatement?: boolean): number;
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* OPTIONAL. Retention removed the sanction rows of a group that still has an `open` appeal (or the group never had a subject row): move
|
|
1348
|
+
* each such appeal to `moot` (`decidedAt` = `at`, `decidedBy` = `by`, no reason), so it leaves the inbox and its statement goes on
|
|
1349
|
+
* the decided clock. A group that is only REVOKED still has its row and is not an orphan. `clearStatement` also nulls the statement
|
|
1350
|
+
* (retention with `appealStatementsMs` at 0). Returns how many moved; moves the change token when it is above 0.
|
|
1351
|
+
*/
|
|
1352
|
+
closeOrphanAppeals?(by: string, at: number, clearStatement?: boolean): number;
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* OPTIONAL. Per rule, the appeals FILED at or after `since`: `appealed` (every status, a moot one included), `granted` (revoked ONLY) and
|
|
1356
|
+
* `lightened` (reduced: a reduction is not a false positive, so it is never counted as granted). `'uncovered'` and a null rule read as
|
|
1357
|
+
* one null rule. A rule with no appeal has no row. In no promised order.
|
|
1358
|
+
*/
|
|
1359
|
+
appealCountsByRule?(since: number): Array<{ rule: string | null; appealed: number; granted: number; lightened: number }>;
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* OPTIONAL. Per rule, the distinct sanction GROUPS whose subject row is a warning, chat, area or ban (never a note, never an IP row)
|
|
1363
|
+
* starting at or after `since`, revoked ones included, EXCLUDING a group that is some appeal's `replacementGroupId` (a reduction is one
|
|
1364
|
+
* sanction, not two). `'uncovered'` and a null rule read as one null rule. In no promised order.
|
|
1365
|
+
*/
|
|
1366
|
+
countSanctionsByRule?(since: number): Array<{ rule: string | null; count: number }>;
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* OPTIONAL. The SUBJECT row of a sanction group (kind, actor, source, automated, start, end, rule, room, `reportId`), revoked or not, as
|
|
1370
|
+
* a copy; null for an unknown group or one with only an IP row. `reportId` and `revokedAt` (when the group was revoked) are present only
|
|
1371
|
+
* when set: this is the one read that carries them.
|
|
1372
|
+
*/
|
|
1373
|
+
loadSanctionSubjectRow?(groupId: string): SanctionRow | null;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* OPTIONAL. Null the statement of every appeal decided (or closed) before `before` (strict: one exactly on the line keeps it). The row
|
|
1377
|
+
* stays. Returns how many statements were cleared. An open appeal is never touched.
|
|
1378
|
+
*/
|
|
1379
|
+
clearAppealStatements?(before: number): number;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* OPTIONAL. Delete appeals decided (or closed) before `before` (strict), EXCEPT one whose sanction group is still in force: a chat, area or
|
|
1383
|
+
* ban, not revoked, that has no end or whose end is after `before` (`before` stands for "now less the retention": a sanction that ended
|
|
1384
|
+
* before it is over). That row is what stops the player appealing a live sanction a second time. An open appeal is never deleted.
|
|
1385
|
+
* Returns how many were deleted.
|
|
1386
|
+
*/
|
|
1387
|
+
purgeAppeals?(before: number): number;
|
|
1388
|
+
|
|
1389
|
+
// Blocked names (offensive names, design 5.2 and 6.3). OPTIONAL: a kit with `names.keepBlocked` needs them. Synchronous. They do not move
|
|
1390
|
+
// the change token: a kept name is evidence on a short clock, not a queue item.
|
|
1391
|
+
|
|
1392
|
+
/** OPTIONAL. Keep one blocked name. */
|
|
1393
|
+
insertBlockedName?(row: BlockedNameRow): void;
|
|
1394
|
+
|
|
1395
|
+
/** OPTIONAL. Kept names at or after `since`, newest first (ties newest-inserted first), at most `limit` (floored, clamped to 1..200). Copies. */
|
|
1396
|
+
listBlockedNames?(since: number, limit: number): BlockedNameRow[];
|
|
1397
|
+
|
|
1398
|
+
/** OPTIONAL. Delete names with `at < before` (a row exactly on the line is kept); returns how many. */
|
|
1399
|
+
purgeBlockedNames?(before: number): number;
|
|
1400
|
+
|
|
1216
1401
|
// Staff audit trail. SYNCHRONOUS on purpose (like sanctions). The trail also holds the rows `closeGap` and the term
|
|
1217
1402
|
// editor write; none of these methods ever returns the json columns those carry (they may hold term text).
|
|
1218
1403
|
|
|
@@ -1268,8 +1453,19 @@ export interface Store {
|
|
|
1268
1453
|
* `report_outcome`, and has `createdAt < before`; or its end is past (`until` set and `< before`). A notice for a
|
|
1269
1454
|
* permanent or still-running sanction is never deleted while it applies, and an unseen warning is kept until it
|
|
1270
1455
|
* is seen or withdrawn.
|
|
1456
|
+
*
|
|
1457
|
+
* The four message kinds (`rename_required`, `appeal_upheld`, `appeal_reduced`, `appeal_revoked`) follow the `report_outcome`
|
|
1458
|
+
* rule when seen (deleted with `createdAt < before`). An UNSEEN one is kept, but not for ever: `unseen`, when given, is a ceiling.
|
|
1459
|
+
* An unseen appeal outcome goes with `createdAt < unseen.appealBefore`, an unseen `rename_required` with
|
|
1460
|
+
* `createdAt < unseen.renameBefore`. Without `unseen` (an older caller) an unseen message notice is kept. A warning and a report
|
|
1461
|
+
* outcome are not affected by it.
|
|
1462
|
+
*
|
|
1463
|
+
* A store written outside this repo that ignores the second argument simply has no ceiling (an unseen message notice is then kept until
|
|
1464
|
+
* it is seen); that is the safe direction, and the release notes say so. The same goes for the optional `closeOrphanAppeals` and for the
|
|
1465
|
+
* trailing `clearStatement` argument of `closeAppealsForGroup`: a store without them keeps an orphaned appeal open and clears a moot
|
|
1466
|
+
* statement on the next purge instead of at once.
|
|
1271
1467
|
*/
|
|
1272
|
-
purgeNotices(before: number): number;
|
|
1468
|
+
purgeNotices(before: number, unseen?: { appealBefore: number; renameBefore: number }): number;
|
|
1273
1469
|
|
|
1274
1470
|
// Webhook idempotency keys (K3b). SYNCHRONOUS on purpose (like sanctions): they run inside `transaction`.
|
|
1275
1471
|
|
|
@@ -1319,6 +1515,13 @@ export interface Store {
|
|
|
1319
1515
|
/** Withdraw every not-yet-withdrawn notice of the group at `at`. Returns how many this call withdrew. */
|
|
1320
1516
|
withdrawNoticeGroup(groupId: string, at: number): number;
|
|
1321
1517
|
|
|
1518
|
+
/**
|
|
1519
|
+
* OPTIONAL. Withdraw one notice by id at `at`, seen or not, whatever its group: for a notice that has no group (a required rename), which
|
|
1520
|
+
* `withdrawNoticeGroup` cannot reach. True only for the call that did it (false for an unknown or an already withdrawn id; the first time
|
|
1521
|
+
* is kept). Touches no other row. A kit over a store without it cannot release a rename, so `names.requireRename` answers `off`.
|
|
1522
|
+
*/
|
|
1523
|
+
withdrawNotice?(id: string, at: number): boolean;
|
|
1524
|
+
|
|
1322
1525
|
/**
|
|
1323
1526
|
* The newest notice of a sanction group that is not withdrawn (newest by `createdAt`, then write order), or null
|
|
1324
1527
|
* when the group has none. Seen or not. `subject` is the stored (possibly since merged) subject the notice is for,
|