@chatwarden/core 0.1.7 → 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 +306 -7
- package/dist/src/ai/case.d.ts +4 -3
- 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 +3 -1
- package/dist/src/ai/hash.d.ts.map +1 -1
- package/dist/src/ai/hash.js +5 -2
- package/dist/src/ai/hash.js.map +1 -1
- package/dist/src/ai/prompt.d.ts +13 -2
- package/dist/src/ai/prompt.d.ts.map +1 -1
- package/dist/src/ai/prompt.js +31 -1
- package/dist/src/ai/prompt.js.map +1 -1
- package/dist/src/ai/service.d.ts +21 -6
- package/dist/src/ai/service.d.ts.map +1 -1
- package/dist/src/ai/service.js +14 -7
- package/dist/src/ai/service.js.map +1 -1
- package/dist/src/ai/types.d.ts +33 -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 +8 -1
- package/dist/src/ai/worker.d.ts.map +1 -1
- package/dist/src/ai/worker.js +17 -3
- 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/chat.d.ts +39 -1
- package/dist/src/chat.d.ts.map +1 -1
- package/dist/src/chat.js +85 -6
- package/dist/src/chat.js.map +1 -1
- package/dist/src/chatwarden.d.ts +197 -10
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +212 -23
- 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 +5 -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/freeze.d.ts +3 -0
- package/dist/src/freeze.d.ts.map +1 -0
- package/dist/src/freeze.js +10 -0
- package/dist/src/freeze.js.map +1 -0
- package/dist/src/index.d.ts +20 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/ladder.d.ts +28 -0
- package/dist/src/ladder.d.ts.map +1 -1
- package/dist/src/ladder.js +37 -1
- package/dist/src/ladder.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/pace.d.ts +66 -0
- package/dist/src/pace.d.ts.map +1 -0
- package/dist/src/pace.js +111 -0
- package/dist/src/pace.js.map +1 -0
- package/dist/src/pacing.d.ts +63 -0
- package/dist/src/pacing.d.ts.map +1 -0
- package/dist/src/pacing.js +198 -0
- package/dist/src/pacing.js.map +1 -0
- package/dist/src/policy.d.ts +66 -1
- package/dist/src/policy.d.ts.map +1 -1
- package/dist/src/policy.js +86 -5
- package/dist/src/policy.js.map +1 -1
- package/dist/src/profile.d.ts +57 -8
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +69 -25
- package/dist/src/profile.js.map +1 -1
- package/dist/src/profileError.d.ts +10 -0
- package/dist/src/profileError.d.ts.map +1 -0
- package/dist/src/profileError.js +17 -0
- package/dist/src/profileError.js.map +1 -0
- package/dist/src/retention.d.ts +40 -1
- package/dist/src/retention.d.ts.map +1 -1
- package/dist/src/retention.js +50 -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/signalCounts.d.ts +37 -0
- package/dist/src/signalCounts.d.ts.map +1 -0
- package/dist/src/signalCounts.js +117 -0
- package/dist/src/signalCounts.js.map +1 -0
- package/dist/src/signalInert.d.ts +10 -0
- package/dist/src/signalInert.d.ts.map +1 -0
- package/dist/src/signalInert.js +28 -0
- package/dist/src/signalInert.js.map +1 -0
- package/dist/src/signalService.d.ts +101 -0
- package/dist/src/signalService.d.ts.map +1 -0
- package/dist/src/signalService.js +383 -0
- package/dist/src/signalService.js.map +1 -0
- package/dist/src/signals.d.ts +186 -0
- package/dist/src/signals.d.ts.map +1 -0
- package/dist/src/signals.js +361 -0
- package/dist/src/signals.js.map +1 -0
- 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/subjects.d.ts +2 -0
- package/dist/src/subjects.d.ts.map +1 -1
- package/dist/src/subjects.js +4 -0
- package/dist/src/subjects.js.map +1 -1
- package/dist/src/team.d.ts +27 -0
- package/dist/src/team.d.ts.map +1 -1
- package/dist/src/team.js +92 -4
- package/dist/src/team.js.map +1 -1
- package/dist/src/types.d.ts +254 -7
- 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 +6 -4
- package/src/ai/hash.ts +5 -2
- package/src/ai/prompt.ts +39 -2
- package/src/ai/service.ts +29 -14
- package/src/ai/types.ts +31 -2
- package/src/ai/worker.ts +20 -4
- package/src/appealService.ts +584 -0
- package/src/appeals.ts +256 -0
- package/src/audit.ts +18 -3
- package/src/chat.ts +109 -8
- package/src/chatwarden.ts +382 -27
- package/src/decide.ts +13 -7
- package/src/documents.ts +8 -3
- package/src/events.ts +23 -1
- package/src/freeze.ts +8 -0
- package/src/index.ts +52 -3
- package/src/ladder.ts +59 -1
- package/src/nameService.ts +255 -0
- package/src/names.ts +121 -0
- package/src/notices.ts +112 -14
- package/src/pace.ts +139 -0
- package/src/pacing.ts +242 -0
- package/src/policy.ts +125 -8
- package/src/profile.ts +115 -25
- package/src/profileError.ts +17 -0
- package/src/retention.ts +79 -3
- package/src/sanctions.ts +72 -9
- package/src/signalCounts.ts +133 -0
- package/src/signalInert.ts +31 -0
- package/src/signalService.ts +406 -0
- package/src/signals.ts +489 -0
- package/src/staffViews.ts +30 -0
- package/src/subjects.ts +5 -0
- package/src/team.ts +93 -5
- package/src/types.ts +275 -8
package/src/team.ts
CHANGED
|
@@ -38,6 +38,11 @@ const NEXT_PAGE = 200;
|
|
|
38
38
|
|
|
39
39
|
/** With `rankDownHabitual`, candidates are ranked this many at a time (see `next`). */
|
|
40
40
|
const RANK_SLICE = 20;
|
|
41
|
+
/** The most "handed to this moderator" markers `next` keeps (the oldest go). */
|
|
42
|
+
const SERVED_MAX = 1000;
|
|
43
|
+
|
|
44
|
+
/** With `signalBoost`, take-next looks at most this many people (oldest first) for an overdue or boosted case. @experimental */
|
|
45
|
+
export const SIGNAL_BOOST_SCAN_MAX = 200;
|
|
41
46
|
|
|
42
47
|
/** A claim as staff see it. Staff only: `by` is a staff actor. */
|
|
43
48
|
export interface CaseClaim {
|
|
@@ -192,8 +197,16 @@ export interface TeamDeps {
|
|
|
192
197
|
reasons?: () => readonly ReportReason[];
|
|
193
198
|
/** How each person's reports have turned out (see `cw.reports.reporterAccuracy`). Without it, `rankDownHabitual` ranks nobody down. */
|
|
194
199
|
accuracy?: (people: readonly SubjectId[]) => Map<SubjectId, ReporterAccuracy>;
|
|
200
|
+
/**
|
|
201
|
+
* Which of these people meet the queue signal feed (`cw.signals.boosted`), as canonical ids. Only asked when `next` is given
|
|
202
|
+
* `signalBoost`, once per page of candidates. Without it nobody is boosted. A throw reads as nobody boosted.
|
|
203
|
+
*/
|
|
204
|
+
boosted?: (people: readonly SubjectId[]) => Set<SubjectId>;
|
|
195
205
|
}
|
|
196
206
|
|
|
207
|
+
/** The key of a lapsed-claim marker: the moderator and the person, apart by a character neither can hold. */
|
|
208
|
+
const markerKey = (actor: string, person: SubjectId): string => `${actor}\u0000${person}`;
|
|
209
|
+
|
|
197
210
|
/** Claims, take next and viewing. The facade exposes it as `cw.cases`. */
|
|
198
211
|
export class CaseDesk {
|
|
199
212
|
private readonly store: Store;
|
|
@@ -201,7 +214,10 @@ export class CaseDesk {
|
|
|
201
214
|
private readonly clock: Clock;
|
|
202
215
|
private readonly reasons: () => readonly ReportReason[];
|
|
203
216
|
private readonly accuracy: NonNullable<TeamDeps['accuracy']>;
|
|
217
|
+
private readonly boosted: TeamDeps['boosted'];
|
|
204
218
|
private readonly presence: ViewingPresence;
|
|
219
|
+
/** `moderator, person` -> when the claim `next` handed that moderator ran out (this process only). See `lapsedByMe`. */
|
|
220
|
+
private readonly served = new Map<string, number>();
|
|
205
221
|
|
|
206
222
|
constructor(deps: TeamDeps) {
|
|
207
223
|
this.store = deps.store;
|
|
@@ -209,6 +225,7 @@ export class CaseDesk {
|
|
|
209
225
|
this.clock = deps.clock;
|
|
210
226
|
this.reasons = deps.reasons ?? (() => []);
|
|
211
227
|
this.accuracy = deps.accuracy ?? (() => new Map());
|
|
228
|
+
this.boosted = deps.boosted;
|
|
212
229
|
this.presence = new ViewingPresence(deps.clock);
|
|
213
230
|
}
|
|
214
231
|
|
|
@@ -243,6 +260,8 @@ export class CaseDesk {
|
|
|
243
260
|
}
|
|
244
261
|
const now = this.clock.now();
|
|
245
262
|
const res = this.store.claimCase(canonical, actor, now, now + CLAIM_TTL_MS, opts.takeOver === true ? 'takeover' : 'claim');
|
|
263
|
+
// The holder keeping the claim alive (or taking it again) is not one who let it lapse.
|
|
264
|
+
if (res.won) this.served.delete(markerKey(actor, canonical));
|
|
246
265
|
return res.won
|
|
247
266
|
? { ok: true, claim: claimOf(res.claim), tookOverFrom: res.from }
|
|
248
267
|
: { ok: false, error: 'claimed', claim: claimOf(res.claim) };
|
|
@@ -254,6 +273,8 @@ export class CaseDesk {
|
|
|
254
273
|
release(person: SubjectId, actor: string): boolean {
|
|
255
274
|
needActor(actor);
|
|
256
275
|
const canonical = this.subjects.canonical(needPerson(person));
|
|
276
|
+
// Released on purpose: not a claim that ran out (`lapsedByMe`).
|
|
277
|
+
this.served.delete(markerKey(actor, canonical));
|
|
257
278
|
return this.store.transaction(() => this.store.releaseClaim(canonical, actor, this.clock.now()));
|
|
258
279
|
}
|
|
259
280
|
|
|
@@ -268,6 +289,8 @@ export class CaseDesk {
|
|
|
268
289
|
const canonical = this.subjects.canonical(needPerson(person));
|
|
269
290
|
return this.store.transaction(() => {
|
|
270
291
|
if (this.store.listOpenReportsByPerson(this.subjects.aliasesOf(canonical), 1).length > 0) return false;
|
|
292
|
+
// Decided and done: the claim ending is not "let it lapse".
|
|
293
|
+
this.served.delete(markerKey(actor, canonical));
|
|
271
294
|
return this.store.releaseClaim(canonical, actor, this.clock.now());
|
|
272
295
|
});
|
|
273
296
|
}
|
|
@@ -283,8 +306,20 @@ export class CaseDesk {
|
|
|
283
306
|
* reporter, or no accuracy data, keeps the case normal). The first normal case in oldest-first order is claimed; ranked-down
|
|
284
307
|
* ones are remembered in order and, when the scan ends (end of the queue, or {@link RANK_DOWN_SCAN_MAX} reports read), the
|
|
285
308
|
* oldest of them is claimed. Nothing is skipped for good: a queue holding only habitual cases still serves them, oldest first.
|
|
309
|
+
*
|
|
310
|
+
* With `signalBoost` (default false: behaviour unchanged), the scan stays oldest first but a case is claimed only when it is OVERDUE (its
|
|
311
|
+
* oldest open report has waited {@link REPORTER_RANK_LAPSE_MS}) or BOOSTED (the person meets the queue signal feed, `TeamDeps.boosted`);
|
|
312
|
+
* the first such case wins. When the queue ends, or {@link SIGNAL_BOOST_SCAN_MAX} people have been looked at, with neither, the oldest
|
|
313
|
+
* free case is claimed as it would be without the filter. A boosted case is never ranked down as a habitual reporter's. Because the
|
|
314
|
+
* queue is oldest first an overdue case is always met before anything newer, so boosted cases cannot starve an old one past 24 hours.
|
|
315
|
+
* Nothing leaves the queue.
|
|
316
|
+
*
|
|
317
|
+
* Also with `signalBoost`: a case `next` handed this moderator whose claim then ran out (they did not decide it, and did not hold it)
|
|
318
|
+
* is served to them after every other free case for one claim window ({@link CLAIM_TTL_MS}) from the moment it ran out, so a boosted or
|
|
319
|
+
* overdue case does not come straight back to the person who let it lapse. Other moderators are not affected, it is still served when it
|
|
320
|
+
* is all that is left, and it is kept in this process only (a restart forgets it).
|
|
286
321
|
*/
|
|
287
|
-
next(actor: string, filter: { category?: ReportCategory; reason?: string | null; rankDownHabitual?: boolean } = {}): NextCase | null {
|
|
322
|
+
next(actor: string, filter: { category?: ReportCategory; reason?: string | null; rankDownHabitual?: boolean; signalBoost?: boolean } = {}): NextCase | null {
|
|
288
323
|
needActor(actor);
|
|
289
324
|
const category = filter.category;
|
|
290
325
|
if (category !== undefined && !REPORT_CATEGORIES.includes(category)) throw new RangeError('cases: unknown category');
|
|
@@ -294,9 +329,19 @@ export class CaseDesk {
|
|
|
294
329
|
const rank = filter.rankDownHabitual;
|
|
295
330
|
if (rank !== undefined && typeof rank !== 'boolean') throw new RangeError('cases: rankDownHabitual must be a boolean');
|
|
296
331
|
const rankDown = rank === true;
|
|
332
|
+
const boost = filter.signalBoost;
|
|
333
|
+
if (boost !== undefined && typeof boost !== 'boolean') throw new RangeError('cases: signalBoost must be a boolean');
|
|
334
|
+
const boostMode = boost === true;
|
|
297
335
|
const seen = new Set<SubjectId>();
|
|
298
336
|
// Ranked-down people in the order the scan met them (oldest first).
|
|
299
337
|
const deferred: SubjectId[] = [];
|
|
338
|
+
// With signalBoost: free people who are neither overdue nor boosted, in scan order, claimed when the scan ends (before the ranked-down).
|
|
339
|
+
const ordinary: SubjectId[] = [];
|
|
340
|
+
// With signalBoost: free people whose claim this moderator let lapse in the last claim window, claimed last of all.
|
|
341
|
+
const lapsed: SubjectId[] = [];
|
|
342
|
+
// With signalBoost: when each person's oldest open report was filed (the first one the scan met), and how many people were looked at.
|
|
343
|
+
const oldestAt = new Map<SubjectId, number>();
|
|
344
|
+
let scanned = 0;
|
|
300
345
|
let read = 0;
|
|
301
346
|
let after: { createdAt: number; id: string } | undefined;
|
|
302
347
|
for (;;) {
|
|
@@ -315,33 +360,53 @@ export class CaseDesk {
|
|
|
315
360
|
if (seen.has(person)) continue;
|
|
316
361
|
seen.add(person);
|
|
317
362
|
candidates.push(person);
|
|
363
|
+
if (boostMode) oldestAt.set(person, report.createdAt);
|
|
364
|
+
}
|
|
365
|
+
if (boostMode) {
|
|
366
|
+
// At most SIGNAL_BOOST_SCAN_MAX people in all, held ones included: they are looked at too.
|
|
367
|
+
candidates.length = Math.max(0, Math.min(candidates.length, SIGNAL_BOOST_SCAN_MAX - scanned));
|
|
368
|
+
scanned += candidates.length;
|
|
318
369
|
}
|
|
319
370
|
const held = new Set(this.store.loadClaims(candidates, this.clock.now()).map((c) => c.person));
|
|
320
371
|
const free = candidates.filter((p) => !held.has(p));
|
|
372
|
+
// One grouped read for the page.
|
|
373
|
+
const boosted = boostMode ? this.boostedAmong(free) : new Set<SubjectId>();
|
|
374
|
+
const now = this.clock.now();
|
|
321
375
|
// Ranked lazily, a slice at a time: the first ordinary case ends the scan, so "next, next, next" does not read the open
|
|
322
376
|
// reports of a whole page of candidates to claim the first one.
|
|
323
377
|
for (let i = 0; i < free.length; i += RANK_SLICE) {
|
|
324
378
|
const slice = free.slice(i, i + RANK_SLICE);
|
|
325
379
|
const down = rankDown ? this.rankedDown(slice) : new Set<SubjectId>();
|
|
326
380
|
for (const person of slice) {
|
|
327
|
-
if (
|
|
381
|
+
if (boostMode && this.lapsedByMe(actor, person, now)) {
|
|
382
|
+
lapsed.push(person);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const isBoosted = boosted.has(person);
|
|
386
|
+
if (down.has(person) && !isBoosted) {
|
|
328
387
|
deferred.push(person);
|
|
329
388
|
continue;
|
|
330
389
|
}
|
|
390
|
+
if (boostMode && !isBoosted && now - (oldestAt.get(person) ?? now) < REPORTER_RANK_LAPSE_MS) {
|
|
391
|
+
ordinary.push(person);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
331
394
|
const won = this.tryClaim(person, actor);
|
|
332
395
|
if (won !== null) return won;
|
|
333
396
|
}
|
|
334
397
|
}
|
|
335
398
|
const last = page[page.length - 1];
|
|
336
399
|
if (page.length < NEXT_PAGE || last === undefined) break;
|
|
400
|
+
if (boostMode && scanned >= SIGNAL_BOOST_SCAN_MAX) break;
|
|
337
401
|
// Enough read to have looked for a normal case: serve the oldest ranked-down one rather than scan the whole queue.
|
|
338
402
|
if (rankDown && read >= RANK_DOWN_SCAN_MAX && deferred.length > 0) break;
|
|
339
403
|
after = { createdAt: last.createdAt, id: last.id };
|
|
340
404
|
}
|
|
341
|
-
|
|
405
|
+
const rest = [...ordinary, ...deferred, ...lapsed];
|
|
406
|
+
if (rest.length === 0) return null;
|
|
342
407
|
// A rival may have taken one meanwhile: one read of the claims, so a held case costs no write.
|
|
343
|
-
const heldNow = new Set(this.store.loadClaims(
|
|
344
|
-
for (const person of
|
|
408
|
+
const heldNow = new Set(this.store.loadClaims(rest, this.clock.now()).map((c) => c.person));
|
|
409
|
+
for (const person of rest) {
|
|
345
410
|
if (heldNow.has(person)) continue;
|
|
346
411
|
const won = this.tryClaim(person, actor);
|
|
347
412
|
if (won !== null) return won;
|
|
@@ -349,6 +414,25 @@ export class CaseDesk {
|
|
|
349
414
|
return null;
|
|
350
415
|
}
|
|
351
416
|
|
|
417
|
+
/** Did a claim `next` handed this moderator on this person run out within the last claim window? Forgets markers older than that. */
|
|
418
|
+
private lapsedByMe(actor: string, person: SubjectId, now: number): boolean {
|
|
419
|
+
const key = markerKey(actor, person);
|
|
420
|
+
const until = this.served.get(key);
|
|
421
|
+
if (until === undefined) return false;
|
|
422
|
+
if (now - until >= CLAIM_TTL_MS) this.served.delete(key);
|
|
423
|
+
return until <= now && now - until < CLAIM_TTL_MS;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Who of these people the queue signal feed boosts (canonical ids). Nobody without the dependency, or when it throws. */
|
|
427
|
+
private boostedAmong(people: readonly SubjectId[]): Set<SubjectId> {
|
|
428
|
+
if (this.boosted === undefined || people.length === 0) return new Set();
|
|
429
|
+
try {
|
|
430
|
+
return this.boosted(people);
|
|
431
|
+
} catch {
|
|
432
|
+
return new Set();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
352
436
|
/** One atomic 'free' claim of a person's case, opened on their newest open report; null when a rival won or the case closed. */
|
|
353
437
|
private tryClaim(person: SubjectId, actor: string): NextCase | null {
|
|
354
438
|
return retryBusy(() =>
|
|
@@ -356,6 +440,10 @@ export class CaseDesk {
|
|
|
356
440
|
const now = this.clock.now();
|
|
357
441
|
const res = this.store.claimCase(person, actor, now, now + CLAIM_TTL_MS, 'free');
|
|
358
442
|
if (!res.won) return null;
|
|
443
|
+
const key = markerKey(actor, person);
|
|
444
|
+
this.served.delete(key);
|
|
445
|
+
this.served.set(key, res.claim.until);
|
|
446
|
+
if (this.served.size > SERVED_MAX) this.served.delete(this.served.keys().next().value!);
|
|
359
447
|
const newest = this.store.listOpenReportsByPerson(this.subjects.aliasesOf(person), 1)[0];
|
|
360
448
|
if (newest === undefined) {
|
|
361
449
|
// The case closed under us: do not leave a claim on nothing.
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Core types for @chatwarden/core. Organized by section; later tasks append
|
|
2
2
|
// their own sections below.
|
|
3
3
|
|
|
4
|
-
import type { AIExample, AIRead } from './ai/types.js';
|
|
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
|
/**
|
|
@@ -270,6 +279,11 @@ export interface AiReadDone extends AiCallUsage {
|
|
|
270
279
|
* hash, so the read records which ones it saw. Ids only; none by default.
|
|
271
280
|
*/
|
|
272
281
|
exampleIds?: readonly string[];
|
|
282
|
+
/**
|
|
283
|
+
* The signal counts about the reported person the prompt carried (`feeds.ai`): exactly what was sent, label, polarity, distinct and window
|
|
284
|
+
* only. Stored with the read (`signals_json`); none (or an empty list) is stored as null.
|
|
285
|
+
*/
|
|
286
|
+
signals?: readonly AISignal[];
|
|
273
287
|
}
|
|
274
288
|
|
|
275
289
|
/**
|
|
@@ -293,6 +307,8 @@ export interface AiReadRow {
|
|
|
293
307
|
read: AIRead | null;
|
|
294
308
|
/** The ids of the casebook examples this read saw (empty when none, and for every row but an `ok` one). */
|
|
295
309
|
exampleIds: readonly string[];
|
|
310
|
+
/** 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. */
|
|
311
|
+
signals: readonly AISignal[] | null;
|
|
296
312
|
inputTokens: number | null;
|
|
297
313
|
outputTokens: number | null;
|
|
298
314
|
cacheReadTokens: number | null;
|
|
@@ -312,6 +328,89 @@ export interface AiReadRow {
|
|
|
312
328
|
retaken: boolean;
|
|
313
329
|
}
|
|
314
330
|
|
|
331
|
+
/**
|
|
332
|
+
* 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
|
|
333
|
+
* text, handle or seat. `sourceKey` is `b:<canonical by>`, `r:<roomId>` or `d:<UTC day>`; `(kind, subject, sourceKey, capBucket)` is unique,
|
|
334
|
+
* which is the per-source cap.
|
|
335
|
+
* @experimental
|
|
336
|
+
*/
|
|
337
|
+
export interface SignalRow {
|
|
338
|
+
id: string;
|
|
339
|
+
kind: string;
|
|
340
|
+
subject: SubjectId;
|
|
341
|
+
/** 'b:<canonical by>' | 'r:<roomId>' | 'd:<UTC day>' */
|
|
342
|
+
sourceKey: string;
|
|
343
|
+
bySubject: SubjectId | null;
|
|
344
|
+
roomId: string | null;
|
|
345
|
+
at: number;
|
|
346
|
+
/** The effective weight, stored at record time (0 or more). */
|
|
347
|
+
weight: number;
|
|
348
|
+
/** floor(at / perByWindowMs): the cap bucket. */
|
|
349
|
+
capBucket: number;
|
|
350
|
+
}
|
|
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
|
+
|
|
398
|
+
/**
|
|
399
|
+
* What `listSignalSources` answers: one row per source of a kind about a subject. Rows are bounded by distinct sources, not by volume.
|
|
400
|
+
* @experimental
|
|
401
|
+
*/
|
|
402
|
+
export interface SignalSourceRow {
|
|
403
|
+
subject: SubjectId;
|
|
404
|
+
kind: string;
|
|
405
|
+
sourceKey: string;
|
|
406
|
+
/** The source's `by` (the smallest, when rows of one source name more than one); null for a room or day source. */
|
|
407
|
+
bySubject: SubjectId | null;
|
|
408
|
+
/** The highest weight among the source's rows in range. */
|
|
409
|
+
weight: number;
|
|
410
|
+
firstAt: number;
|
|
411
|
+
lastAt: number;
|
|
412
|
+
}
|
|
413
|
+
|
|
315
414
|
/**
|
|
316
415
|
* 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
|
|
317
416
|
* caller's fence token (the row's `attempts` after this reserve): `completeAiRead` and `failAiRead` must be given it, and do nothing
|
|
@@ -364,14 +463,21 @@ export interface AiOutcomeInsert {
|
|
|
364
463
|
|
|
365
464
|
/** A stored outcome: what was inserted, and the two marks a later action sets. */
|
|
366
465
|
export interface AiOutcomeRow extends AiOutcomeInsert {
|
|
367
|
-
/** 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`. */
|
|
368
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;
|
|
369
473
|
/** A senior's mark. Excludes the row from examples. */
|
|
370
474
|
dontTeach: boolean;
|
|
371
475
|
}
|
|
372
476
|
|
|
373
477
|
/** One teachable casebook example, newest first from {@link Store.aiExamples}. The human's final decision is the label. */
|
|
374
478
|
export interface AiExampleRow {
|
|
479
|
+
/** `'corrective'` for a decision a granted (revoked) appeal found wrong; absent for an ordinary example. */
|
|
480
|
+
kind?: 'corrective';
|
|
375
481
|
reportId: string;
|
|
376
482
|
decidedAt: number;
|
|
377
483
|
agreement: 'agree' | 'override';
|
|
@@ -665,8 +771,21 @@ export interface ReportActivity {
|
|
|
665
771
|
// Notices (storage shape)
|
|
666
772
|
// ---------------------------------------------------------------------------
|
|
667
773
|
|
|
668
|
-
/**
|
|
669
|
-
|
|
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';
|
|
670
789
|
|
|
671
790
|
/**
|
|
672
791
|
* One stored player notice. `subject` is the CANONICAL subject at write time (a later merge is resolved at query
|
|
@@ -678,7 +797,7 @@ export interface NoticeRow {
|
|
|
678
797
|
/** Random, never derived. */
|
|
679
798
|
id: string;
|
|
680
799
|
subject: SubjectId;
|
|
681
|
-
/** 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. */
|
|
682
801
|
groupId: string | null;
|
|
683
802
|
kind: NoticeKind;
|
|
684
803
|
rule: string | null;
|
|
@@ -1120,14 +1239,17 @@ export interface Store {
|
|
|
1120
1239
|
|
|
1121
1240
|
/**
|
|
1122
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
|
|
1123
|
-
* 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.
|
|
1124
1244
|
*/
|
|
1125
|
-
markAiOutcome?(reportId: string, patch: { reversed?: true; dontTeach?: true }): boolean;
|
|
1245
|
+
markAiOutcome?(reportId: string, patch: { reversed?: true; dontTeach?: true; corrective?: true }): boolean;
|
|
1126
1246
|
|
|
1127
1247
|
/**
|
|
1128
1248
|
* OPTIONAL. Teachable examples with this human rule (`'3'`, `'uncovered'`) and conduct level, decided at or after `since`, newest
|
|
1129
1249
|
* first (`decidedAt` descending, then `reportId` descending), at most `limit`. Teachable: an example is
|
|
1130
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`.
|
|
1131
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
|
|
1132
1254
|
* examples).
|
|
1133
1255
|
*/
|
|
@@ -1149,6 +1271,133 @@ export interface Store {
|
|
|
1149
1271
|
*/
|
|
1150
1272
|
purgeAi?(readsBefore: number, outcomesBefore: number, examplesBefore: number): { reads: number; outcomes: number };
|
|
1151
1273
|
|
|
1274
|
+
// Signals (flood control and signals, design 5.8). OPTIONAL: a store without them cannot keep signals, and `createChatwarden` refuses a
|
|
1275
|
+
// profile that declares kinds or feeds with one. SYNCHRONOUS on purpose (like claims); they run inside `transaction`. They do not move
|
|
1276
|
+
// the change token.
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* OPTIONAL. Insert one signal as ONE atomic statement: false, and nothing written, when a row with the same `(kind, subject, sourceKey,
|
|
1280
|
+
* capBucket)` exists (the per-source cap; of two callers, two processes on one database included, exactly one writes) or the id is
|
|
1281
|
+
* taken. True when a row was written.
|
|
1282
|
+
*/
|
|
1283
|
+
insertSignal?(row: SignalRow): boolean;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* OPTIONAL. One row per `(subject, kind, sourceKey)` that has a row at or after `since`, for these subjects (a person's canonical id and
|
|
1287
|
+
* aliases): the highest weight, the earliest and the latest `at` among the rows in range. No subjects: `[]`. Returns copies.
|
|
1288
|
+
*/
|
|
1289
|
+
listSignalSources?(subjects: readonly SubjectId[], since: number): SignalSourceRow[];
|
|
1290
|
+
|
|
1291
|
+
/** OPTIONAL. Delete rows with `at < before` (a row exactly on the line is kept); returns how many. */
|
|
1292
|
+
purgeSignals?(before: number): number;
|
|
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
|
+
|
|
1152
1401
|
// Staff audit trail. SYNCHRONOUS on purpose (like sanctions). The trail also holds the rows `closeGap` and the term
|
|
1153
1402
|
// editor write; none of these methods ever returns the json columns those carry (they may hold term text).
|
|
1154
1403
|
|
|
@@ -1204,8 +1453,19 @@ export interface Store {
|
|
|
1204
1453
|
* `report_outcome`, and has `createdAt < before`; or its end is past (`until` set and `< before`). A notice for a
|
|
1205
1454
|
* permanent or still-running sanction is never deleted while it applies, and an unseen warning is kept until it
|
|
1206
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.
|
|
1207
1467
|
*/
|
|
1208
|
-
purgeNotices(before: number): number;
|
|
1468
|
+
purgeNotices(before: number, unseen?: { appealBefore: number; renameBefore: number }): number;
|
|
1209
1469
|
|
|
1210
1470
|
// Webhook idempotency keys (K3b). SYNCHRONOUS on purpose (like sanctions): they run inside `transaction`.
|
|
1211
1471
|
|
|
@@ -1255,6 +1515,13 @@ export interface Store {
|
|
|
1255
1515
|
/** Withdraw every not-yet-withdrawn notice of the group at `at`. Returns how many this call withdrew. */
|
|
1256
1516
|
withdrawNoticeGroup(groupId: string, at: number): number;
|
|
1257
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
|
+
|
|
1258
1525
|
/**
|
|
1259
1526
|
* The newest notice of a sanction group that is not withdrawn (newest by `createdAt`, then write order), or null
|
|
1260
1527
|
* when the group has none. Seen or not. `subject` is the stored (possibly since merged) subject the notice is for,
|