@stage5/lumine 0.2.19 → 0.2.20
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/lib/admin.js +125 -5
- package/lib/commands.js +11 -2
- package/package.json +1 -1
- package/sdk/LUMINE_ADMIN.md +236 -44
package/lib/admin.js
CHANGED
|
@@ -4,6 +4,10 @@ import { requestJson } from "./http.js";
|
|
|
4
4
|
|
|
5
5
|
export async function adminCommand(options) {
|
|
6
6
|
const operation = parseAdminOperation(options);
|
|
7
|
+
const recommendationContentTypes =
|
|
8
|
+
operation.name === "recommendations.list"
|
|
9
|
+
? parseRecommendationContentTypes(options.adminContentTypes)
|
|
10
|
+
: null;
|
|
7
11
|
const auth = await resolveAuth(options);
|
|
8
12
|
await assertAuthScope({
|
|
9
13
|
options,
|
|
@@ -54,6 +58,12 @@ export async function adminCommand(options) {
|
|
|
54
58
|
},
|
|
55
59
|
timeoutMs: options.timeoutMs,
|
|
56
60
|
});
|
|
61
|
+
if (recommendationContentTypes) {
|
|
62
|
+
result = filterRecommendationQueueResult({
|
|
63
|
+
result,
|
|
64
|
+
contentTypes: recommendationContentTypes,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
57
67
|
} catch (error) {
|
|
58
68
|
if (operation.mutates && requestId) {
|
|
59
69
|
const retryInstruction = `Retry with --idempotency-key ${requestId}.`;
|
|
@@ -90,6 +100,49 @@ export async function adminCommand(options) {
|
|
|
90
100
|
return result;
|
|
91
101
|
}
|
|
92
102
|
|
|
103
|
+
const RECOMMENDATION_CONTENT_TYPES = new Map([
|
|
104
|
+
["comment", "comment"],
|
|
105
|
+
["aistory", "aiStory"],
|
|
106
|
+
["dailyreflection", "dailyReflection"],
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
export function parseRecommendationContentTypes(value) {
|
|
110
|
+
const raw = String(value || "").trim();
|
|
111
|
+
if (!raw) return null;
|
|
112
|
+
const contentTypes = raw
|
|
113
|
+
.split(",")
|
|
114
|
+
.map((item) => item.trim())
|
|
115
|
+
.filter(Boolean)
|
|
116
|
+
.map((item) => RECOMMENDATION_CONTENT_TYPES.get(item.toLowerCase()));
|
|
117
|
+
if (
|
|
118
|
+
contentTypes.length === 0 ||
|
|
119
|
+
contentTypes.some((contentType) => !contentType) ||
|
|
120
|
+
new Set(contentTypes).size !== contentTypes.length
|
|
121
|
+
) {
|
|
122
|
+
throw cliValidationError(
|
|
123
|
+
"--content-types accepts comment, aiStory, and dailyReflection.",
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return [...new Set(contentTypes)];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function filterRecommendationQueueResult({ result, contentTypes }) {
|
|
130
|
+
const items = Array.isArray(result?.data?.items) ? result.data.items : [];
|
|
131
|
+
const allowed = new Set(contentTypes);
|
|
132
|
+
const filteredItems = items.filter((item) => allowed.has(item?.contentType));
|
|
133
|
+
return {
|
|
134
|
+
...result,
|
|
135
|
+
data: {
|
|
136
|
+
...result.data,
|
|
137
|
+
items: filteredItems,
|
|
138
|
+
clientFilter: {
|
|
139
|
+
contentTypes,
|
|
140
|
+
excludedItems: items.length - filteredItems.length,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
93
146
|
function adminOperationRequiresRun(operation) {
|
|
94
147
|
return ![
|
|
95
148
|
"identity.list",
|
|
@@ -178,6 +231,7 @@ export function parseAdminOperation(options) {
|
|
|
178
231
|
"recommendations.list",
|
|
179
232
|
withQuery("/cli/admin/recommendations", {
|
|
180
233
|
kind,
|
|
234
|
+
contentTypes: options.adminContentTypes,
|
|
181
235
|
cursor: options.adminCursor,
|
|
182
236
|
limit: options.limit,
|
|
183
237
|
}),
|
|
@@ -279,6 +333,23 @@ export function parseAdminOperation(options) {
|
|
|
279
333
|
if (action === "recommend") {
|
|
280
334
|
return recommendOperation(target, options);
|
|
281
335
|
}
|
|
336
|
+
if (action === "skip") {
|
|
337
|
+
const parsedTarget = parseRecommendationTarget({
|
|
338
|
+
target,
|
|
339
|
+
explicitType: options.adminType,
|
|
340
|
+
});
|
|
341
|
+
if (parsedTarget.type === "subject") {
|
|
342
|
+
throw cliValidationError(
|
|
343
|
+
"Skips apply to comment, aiStory, and dailyReflection targets; subjects leave the queue through effort assignment.",
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
return writeOperation(
|
|
347
|
+
"post.skip",
|
|
348
|
+
"POST",
|
|
349
|
+
`/cli/admin/skips/${parsedTarget.type}/${parsedTarget.id}`,
|
|
350
|
+
{ reason: options.adminReason || undefined },
|
|
351
|
+
);
|
|
352
|
+
}
|
|
282
353
|
if (action === "reward") {
|
|
283
354
|
const parsedTarget = parseRecommendationTarget({
|
|
284
355
|
target,
|
|
@@ -303,15 +374,42 @@ export function parseAdminOperation(options) {
|
|
|
303
374
|
return recommendOperation(action, options);
|
|
304
375
|
}
|
|
305
376
|
|
|
377
|
+
if (namespace === "audit" && (!action || action === "list")) {
|
|
378
|
+
const runFilter = String(options.adminRun || "").trim();
|
|
379
|
+
if (runFilter && !["current", "last"].includes(runFilter)) {
|
|
380
|
+
parseRequiredInteger(runFilter, "--run", 1);
|
|
381
|
+
}
|
|
382
|
+
return readOperation(
|
|
383
|
+
"audit.list",
|
|
384
|
+
withQuery("/cli/admin/audit", {
|
|
385
|
+
run: runFilter,
|
|
386
|
+
target: options.adminTarget,
|
|
387
|
+
actions: options.adminActions,
|
|
388
|
+
cursor: options.adminCursor,
|
|
389
|
+
limit: options.limit,
|
|
390
|
+
full: options.adminFull ? "true" : "",
|
|
391
|
+
}),
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
306
395
|
if (namespace === "comment") {
|
|
307
|
-
if (action === "draft") {
|
|
308
|
-
const
|
|
396
|
+
if (action === "draft" || action === "reply") {
|
|
397
|
+
const parsedTarget = parseRecommendationTarget({
|
|
398
|
+
target,
|
|
399
|
+
explicitType: options.adminType,
|
|
400
|
+
});
|
|
401
|
+
if (action === "reply" && parsedTarget.type !== "comment") {
|
|
402
|
+
throw cliValidationError(
|
|
403
|
+
"comment reply targets a comment: lumine admin comment reply comment:<id>.",
|
|
404
|
+
);
|
|
405
|
+
}
|
|
309
406
|
return writeOperation(
|
|
310
407
|
"comment.draft",
|
|
311
408
|
"POST",
|
|
312
409
|
"/cli/admin/comment-drafts",
|
|
313
410
|
{
|
|
314
|
-
|
|
411
|
+
targetType: parsedTarget.type,
|
|
412
|
+
targetId: parsedTarget.id,
|
|
315
413
|
identity: options.adminIdentity
|
|
316
414
|
? parseIdentity(options.adminIdentity)
|
|
317
415
|
: undefined,
|
|
@@ -334,7 +432,7 @@ export function parseAdminOperation(options) {
|
|
|
334
432
|
}
|
|
335
433
|
|
|
336
434
|
throw cliValidationError(
|
|
337
|
-
"Usage: lumine admin identity|daily-run|recommendations|post|subjects|subject|featured|comment ...",
|
|
435
|
+
"Usage: lumine admin identity|daily-run|recommendations|post|subjects|subject|featured|comment|audit ...",
|
|
338
436
|
);
|
|
339
437
|
}
|
|
340
438
|
|
|
@@ -687,6 +785,27 @@ function printAdminResult({ operation, result }) {
|
|
|
687
785
|
printPagination(data.pagination);
|
|
688
786
|
return;
|
|
689
787
|
}
|
|
788
|
+
if (Array.isArray(data.events)) {
|
|
789
|
+
console.log(`${data.events.length} audit event(s):`);
|
|
790
|
+
for (const event of data.events) {
|
|
791
|
+
const target =
|
|
792
|
+
event.targetType && event.targetId
|
|
793
|
+
? ` ${event.targetType}:${event.targetId}`
|
|
794
|
+
: "";
|
|
795
|
+
console.log(
|
|
796
|
+
`#${event.id} run ${event.runId ?? "-"} ${event.action}${target} — ${event.result}${event.changed === true ? " (changed)" : event.changed === false ? " (no change)" : ""}`,
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
printPagination(data.pagination);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (data.skip) {
|
|
803
|
+
console.log(
|
|
804
|
+
`${result.status}: ${data.skip.contentType}:${data.skip.contentId} skipped.`,
|
|
805
|
+
);
|
|
806
|
+
if (data.skip.url) console.log(data.skip.url);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
690
809
|
if (Array.isArray(data.items)) {
|
|
691
810
|
console.log(`${data.items.length} recommendation candidate(s):`);
|
|
692
811
|
for (const item of data.items) {
|
|
@@ -719,7 +838,8 @@ function printAdminResult({ operation, result }) {
|
|
|
719
838
|
`Draft #${data.draft.id}: ${data.draft.decision} (${data.draft.status}).`,
|
|
720
839
|
);
|
|
721
840
|
if (data.draft.content) console.log(data.draft.content);
|
|
722
|
-
|
|
841
|
+
const draftUrl = data.draft.targetUrl || data.draft.subjectUrl;
|
|
842
|
+
if (draftUrl) console.log(draftUrl);
|
|
723
843
|
return;
|
|
724
844
|
}
|
|
725
845
|
if (data.subject) {
|
package/lib/commands.js
CHANGED
|
@@ -2096,6 +2096,7 @@ export function parseArgs(args) {
|
|
|
2096
2096
|
"noBrowser",
|
|
2097
2097
|
"includeComments",
|
|
2098
2098
|
"anyoneCanReward",
|
|
2099
|
+
"full",
|
|
2099
2100
|
]);
|
|
2100
2101
|
|
|
2101
2102
|
for (let i = 0; i < rest.length; i += 1) {
|
|
@@ -2175,6 +2176,7 @@ export function parseArgs(args) {
|
|
|
2175
2176
|
: "",
|
|
2176
2177
|
adminType: raw.type ? String(raw.type) : "",
|
|
2177
2178
|
adminKind: raw.kind ? String(raw.kind) : "",
|
|
2179
|
+
adminContentTypes: raw.contentTypes ? String(raw.contentTypes) : "",
|
|
2178
2180
|
adminIdentity: raw.identity ? String(raw.identity) : "",
|
|
2179
2181
|
commentMode: raw.commentMode ? String(raw.commentMode) : "",
|
|
2180
2182
|
runKey: raw.runKey ? String(raw.runKey) : "",
|
|
@@ -2182,6 +2184,10 @@ export function parseArgs(args) {
|
|
|
2182
2184
|
draftId: raw.draftId ? String(raw.draftId) : "",
|
|
2183
2185
|
twinkles: raw.twinkles ? String(raw.twinkles) : "",
|
|
2184
2186
|
adminReason: raw.reason ? String(raw.reason) : "",
|
|
2187
|
+
adminRun: raw.run ? String(raw.run) : "",
|
|
2188
|
+
adminTarget: raw.target ? String(raw.target) : "",
|
|
2189
|
+
adminActions: raw.actions ? String(raw.actions) : "",
|
|
2190
|
+
adminFull: parseBoolean(raw.full, false),
|
|
2185
2191
|
rewardTwinkles: raw.rewardTwinkles ? String(raw.rewardTwinkles) : "",
|
|
2186
2192
|
includeComments: parseBoolean(raw.includeComments, false),
|
|
2187
2193
|
anyoneCanReward: parseBoolean(raw.anyoneCanReward, false),
|
|
@@ -2500,7 +2506,7 @@ export function printHelp() {
|
|
|
2500
2506
|
lumine admin identity list|status|use <zero|ciel|auto> [--json]
|
|
2501
2507
|
lumine admin daily-run start [--identity zero|ciel|auto] [--comment-mode off|draft|post] [--run-key <key>] [--json]
|
|
2502
2508
|
lumine admin daily-run status|complete|fail [--reason <text>] [--json]
|
|
2503
|
-
lumine admin recommendations list [--cursor <cursor>] [--json]
|
|
2509
|
+
lumine admin recommendations list [--content-types comment,dailyReflection] [--cursor <cursor>] [--json]
|
|
2504
2510
|
lumine admin subjects candidates [--after <date>] [--effort unassigned] [--cursor <cursor>] [--json]
|
|
2505
2511
|
lumine admin subject get|comments|reveal <subject-url-or-id> [--cursor <cursor>] [--json]
|
|
2506
2512
|
lumine admin subject effort set <subject-id> --level <1|2|3> [--json]
|
|
@@ -2509,9 +2515,12 @@ export function printHelp() {
|
|
|
2509
2515
|
lumine admin featured list|reorder --subject-ids <id,id,...> [--json]
|
|
2510
2516
|
lumine admin post get|comments <target> [--type subject|comment|aiStory|dailyReflection] [--cursor <cursor>] [--json]
|
|
2511
2517
|
lumine admin post recommend <target> [--type subject|comment|aiStory|dailyReflection] [--anyone-can-reward] [--reward-twinkles 3] [--json]
|
|
2518
|
+
lumine admin post skip <target> [--type comment|aiStory|dailyReflection] [--reason <text>] [--json]
|
|
2512
2519
|
lumine admin post reward <target> [--type subject|comment|aiStory|dailyReflection] --twinkles 3 [--json]
|
|
2513
|
-
lumine admin comment draft <
|
|
2520
|
+
lumine admin comment draft <target> [--type subject|comment|aiStory|dailyReflection] [--identity zero|ciel|auto] [--json]
|
|
2521
|
+
lumine admin comment reply comment:<id> [--identity zero|ciel|auto] [--json]
|
|
2514
2522
|
lumine admin comment post --draft-id <id> [--json]
|
|
2523
|
+
lumine admin audit [list] [--run current|last|<run-id>] [--target <target>] [--actions <a,b>] [--full] [--cursor <cursor>] [--json]
|
|
2515
2524
|
|
|
2516
2525
|
Examples:
|
|
2517
2526
|
npx @stage5/lumine@latest
|
package/package.json
CHANGED
package/sdk/LUMINE_ADMIN.md
CHANGED
|
@@ -273,9 +273,26 @@ type DailyRunFail = DailyRunComplete;
|
|
|
273
273
|
|
|
274
274
|
`lastRun` makes a lost-response retry of `complete` or `fail` possible after
|
|
275
275
|
the active pointer has been cleared. Other run-scoped commands accept only the
|
|
276
|
-
current unexpired `active` run. Completion
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
current unexpired `active` run. Completion first finalizes any mutation whose
|
|
277
|
+
content change committed but whose audit bookkeeping was still pending,
|
|
278
|
+
counting it toward the run's rotation signal. It then rejects only while a
|
|
279
|
+
mutation from the last ten minutes is genuinely in flight (the 409 lists the
|
|
280
|
+
pending mutations and a `retryAfterSeconds`); older in-flight rows are treated
|
|
281
|
+
as orphans of a dead process and no longer block completion. `fail` remains
|
|
282
|
+
available to abandon a run without advancing rotation, including a run whose
|
|
283
|
+
six-hour authorization has expired; an expired run can never be completed.
|
|
284
|
+
A TTL-expired run is reported with status `expired` even before the next
|
|
285
|
+
start reaps it, so `daily-run status` never shows an unusable run as
|
|
286
|
+
`active`.
|
|
287
|
+
|
|
288
|
+
Starting with a run key that belongs to a finished or expired run fails with
|
|
289
|
+
`CLI_ADMIN_RUN_KEY_ALREADY_USED`; supply a fresh `--run-key` (for example
|
|
290
|
+
`daily:2026-08-07:2`) to start again the same day. Reusing the key of the
|
|
291
|
+
live active run returns that run only when the requested `--comment-mode`
|
|
292
|
+
and any explicit `--identity` match it; otherwise the start fails with
|
|
293
|
+
`CLI_ADMIN_RUN_SETTINGS_MISMATCH` instead of silently returning a run with
|
|
294
|
+
different scopes. The same check applies when a start without the active
|
|
295
|
+
run's key would fall back to that active run.
|
|
279
296
|
|
|
280
297
|
The default run key is `daily:YYYY-MM-DD` in Asia/Bangkok. Supply `--run-key`
|
|
281
298
|
for a separate explicit run. `--idempotency-key` may be supplied to any
|
|
@@ -286,7 +303,8 @@ JSON error includes `details.retryIdempotencyKey` for a safe exact retry.
|
|
|
286
303
|
## Canonical lists and inspection
|
|
287
304
|
|
|
288
305
|
```bash
|
|
289
|
-
lumine admin recommendations list --kind recommend
|
|
306
|
+
lumine admin recommendations list --kind recommend \
|
|
307
|
+
--content-types comment,dailyReflection --cursor '<cursor>' --json
|
|
290
308
|
lumine admin subjects candidates --after 2026-08-01T00:00:00Z \
|
|
291
309
|
--cursor '<cursor>' --json
|
|
292
310
|
lumine admin subjects candidates --effort unassigned --json
|
|
@@ -321,20 +339,37 @@ type RecommendationQueueList = Success<{
|
|
|
321
339
|
recommendation: RecommendationState;
|
|
322
340
|
reward: RewardState;
|
|
323
341
|
}>;
|
|
324
|
-
pagination: Pagination & {
|
|
342
|
+
pagination: Pagination & {
|
|
343
|
+
scannedCount: number;
|
|
344
|
+
contentTypes?: Array<"comment" | "aiStory" | "dailyReflection">;
|
|
345
|
+
};
|
|
346
|
+
clientFilter?: {
|
|
347
|
+
contentTypes: Array<"comment" | "aiStory" | "dailyReflection">;
|
|
348
|
+
excludedItems: number;
|
|
349
|
+
};
|
|
325
350
|
}>;
|
|
326
351
|
|
|
327
352
|
type SubjectCandidates = Success<{
|
|
328
353
|
subjects: Subject[];
|
|
329
|
-
pagination: Pagination;
|
|
354
|
+
pagination: Pagination & { scannedCount: number };
|
|
330
355
|
}>;
|
|
331
356
|
```
|
|
332
357
|
|
|
333
358
|
Both cursors freeze a primary-key high-water mark and traverse descending IDs,
|
|
334
|
-
so concurrent inserts cannot shift or duplicate later pages.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
359
|
+
so concurrent inserts cannot shift or duplicate later pages. Both walks scan a
|
|
360
|
+
bounded primary-key window (500 rows) per call before applying their residual
|
|
361
|
+
filters, so a page — recommendation or subject — can be empty while `hasMore`
|
|
362
|
+
remains true; continue until `exhausted`. Subject `--after` is inclusive, and
|
|
363
|
+
the opaque cursor is bound to its original date and effort filters.
|
|
364
|
+
|
|
365
|
+
`--content-types` is sent to APIs that support server-side filtering so excluded
|
|
366
|
+
types do not run their eligibility/content queries. The local CLI also filters
|
|
367
|
+
the returned page defensively for deployment compatibility. The server cursor
|
|
368
|
+
still advances across every underlying feed row, so excluding `aiStory` cannot
|
|
369
|
+
create gaps in later comment or Daily Reflection pages. New server cursors bind
|
|
370
|
+
the canonical content-type set; one legacy unbound cursor can be resumed and is
|
|
371
|
+
then reissued as bound. `clientFilter.excludedItems` makes any client-side
|
|
372
|
+
filtering explicit in JSON output.
|
|
338
373
|
|
|
339
374
|
For a run-scoped command, `--identity zero|ciel` is an assertion against the
|
|
340
375
|
server-selected run identity; it cannot switch actors locally. A mismatch
|
|
@@ -343,9 +378,14 @@ selection.
|
|
|
343
378
|
|
|
344
379
|
### Query and index design
|
|
345
380
|
|
|
346
|
-
Subject and queue traversal are bounded primary-key walks; the
|
|
347
|
-
most 500 `
|
|
348
|
-
|
|
381
|
+
Subject and queue traversal are bounded primary-key walks; the subject walk
|
|
382
|
+
reads at most 500 `content_subjects` rows per cursor step, and the queue reads
|
|
383
|
+
at most 500 `noti_feeds` rows per cursor step before applying the existing Earn
|
|
384
|
+
Recommend eligibility predicates. The effort projection's
|
|
385
|
+
`UPDATE noti_feeds ... WHERE type = 'subject' AND contentId = ?` reuses the
|
|
386
|
+
website's canonical reward-level projection shape; deployment should verify
|
|
387
|
+
`noti_feeds` carries an index whose leading columns cover `(type, contentId)`
|
|
388
|
+
(or `(contentId, ...)`) as the canonical route already requires. The joins/`NOT EXISTS` checks are necessary
|
|
349
389
|
to preserve the normal recommendation and skip rules, but they run only for
|
|
350
390
|
IDs in that bounded window. Subject-comment traversal uses
|
|
351
391
|
`idx_comments_isDeleted_subject_id`; standalone-post comments use the existing
|
|
@@ -414,7 +454,13 @@ type SubjectGet = Success<{
|
|
|
414
454
|
answer: string | null;
|
|
415
455
|
attachment: unknown | null;
|
|
416
456
|
};
|
|
457
|
+
// True only when comments were actually returned; a secret-gated subject
|
|
458
|
+
// reports false here (with secret.shown false) even when they were
|
|
459
|
+
// requested.
|
|
417
460
|
commentsIncluded: boolean;
|
|
461
|
+
// The inline list is capped at 200 comments in conversation order; when
|
|
462
|
+
// true, page through `subject comments` for the rest.
|
|
463
|
+
commentsTruncated: boolean;
|
|
418
464
|
comments: Comment[];
|
|
419
465
|
};
|
|
420
466
|
}>;
|
|
@@ -503,7 +549,11 @@ type FeaturedReorder = SubjectFeature;
|
|
|
503
549
|
`reveal` publishes the existing hidden “viewed without responding” notification
|
|
504
550
|
as the selected bot, with the ordinary notification and socket side effects.
|
|
505
551
|
Effort assignment rejects an unrevealed secret subject. Creator attribution
|
|
506
|
-
requires an attachment.
|
|
552
|
+
requires an attachment. Both effort assignment and creator attribution enforce
|
|
553
|
+
the website's moderator-precedence rule: when a strictly higher-level
|
|
554
|
+
moderator recorded the current value, the mutation fails with
|
|
555
|
+
`CLI_ADMIN_MODERATOR_PRECEDENCE` (the bots compare at the shared canonical
|
|
556
|
+
effective level). Every response is reloaded from the writer.
|
|
507
557
|
|
|
508
558
|
Featured reorder is a complete-set replacement: it rejects duplicates,
|
|
509
559
|
unknown/deleted IDs, missing current members, non-subject rows, and more than
|
|
@@ -596,27 +646,124 @@ writer-locked state. A new approval reports the canonical 10-point contribution;
|
|
|
596
646
|
a retry reports zero newly awarded and the same confirmed absolute balance.
|
|
597
647
|
|
|
598
648
|
Recommendation history is checked across both management bots, so rotation
|
|
599
|
-
does not recommend the same target again
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
649
|
+
does not recommend the same target again — unless the request asks for
|
|
650
|
+
`--anyone-can-reward` and the other bot's recommendation does not carry that
|
|
651
|
+
permission, in which case the actor proceeds with its own recommendation so
|
|
652
|
+
the requested permission and paired reward are honored rather than silently
|
|
653
|
+
dropped. When the other bot's recommendation does satisfy the request, the
|
|
654
|
+
`managementBotDeduplication` payload is returned and any requested 3-Twinkle
|
|
655
|
+
reward is still processed. A bare recommend never downgrades an existing
|
|
656
|
+
recommendation's anyone-can-reward permission; only an explicit
|
|
657
|
+
`--anyone-can-reward` changes it, and only in the granting direction.
|
|
658
|
+
Changing only `anyoneCanReward` does not rerun prior-recommender approval.
|
|
659
|
+
Approval reward rows are locked and writer-read, so concurrent or restored
|
|
660
|
+
attempts cannot insert the same approval twice.
|
|
603
661
|
|
|
604
662
|
Both the standalone and combined reward paths also inspect existing 3-Twinkle
|
|
605
663
|
management rewards across Zero and Ciel. A canonical three from either bot is
|
|
606
664
|
reported as already rewarded instead of adding another management reward.
|
|
607
665
|
|
|
608
666
|
The separate 3-Twinkle reward targets the worthwhile canonical post or comment.
|
|
609
|
-
It uses the selected bot and Twinkle's ordinary canonical
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
667
|
+
It uses the selected bot and Twinkle's ordinary canonical Level and recipient
|
|
668
|
+
rules; Mikey is never charged while Zero/Ciel is displayed. Zero and Ciel are
|
|
669
|
+
exempt from recommendation and reward coin charges in the shared canonical
|
|
670
|
+
mutation helpers, so neither `insufficient_coins` nor a bot balance decrease
|
|
671
|
+
can occur for these actors; every human actor still pays under the existing
|
|
672
|
+
Level-based rules. The
|
|
613
673
|
reward transaction serializes the rewarder and cap-bearing content row, then
|
|
614
674
|
adds only the amount needed for that actor to total exactly three. Existing
|
|
615
675
|
three is `already_done`; a cap is `maximum_reached`.
|
|
616
676
|
If recommendation succeeds but reward fails, the command exits nonzero with
|
|
617
677
|
`partial_failure` and `retrySafe: true`.
|
|
618
678
|
|
|
619
|
-
##
|
|
679
|
+
## Skip decisions
|
|
680
|
+
|
|
681
|
+
```bash
|
|
682
|
+
lumine admin post skip dailyReflection:99 --json
|
|
683
|
+
lumine admin post skip comment:456 --reason "one-line answer, nothing to add" --json
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
A skip records that the management rotation has judged a recommend-queue item
|
|
687
|
+
and decided not to act, so neither bot's queue resurfaces it. It writes the
|
|
688
|
+
same canonical `users_earn_skip_status` row the website's Earn page writes
|
|
689
|
+
(`earnType 'karma'`, `action 'recommendation'`) under the acting bot, and the
|
|
690
|
+
queue eligibility predicates honor either bot's row. Human moderators' own
|
|
691
|
+
Earn queues are deliberately unaffected: the bots are not database supermods,
|
|
692
|
+
so a bot skip never hides content from a human, who may judge differently.
|
|
693
|
+
|
|
694
|
+
Targets are `comment`, `aiStory`, and `dailyReflection` only; subjects leave
|
|
695
|
+
their queue through effort assignment. Skipping an already-skipped item (by
|
|
696
|
+
either bot) returns `already_done` with `changed: false`. The optional
|
|
697
|
+
`--reason` (at most 500 characters) is stored in the private audit row's
|
|
698
|
+
metadata — it is the agent's memory of the judgment, not public content.
|
|
699
|
+
The skip requires the `recommendation:write` scope and is audited like every
|
|
700
|
+
other mutation.
|
|
701
|
+
|
|
702
|
+
```ts
|
|
703
|
+
type PostSkip = Success<{
|
|
704
|
+
skip: {
|
|
705
|
+
contentType: "comment" | "aiStory" | "dailyReflection";
|
|
706
|
+
contentId: number;
|
|
707
|
+
url: string;
|
|
708
|
+
skippedByUserId: number;
|
|
709
|
+
skippedAt: number | null;
|
|
710
|
+
};
|
|
711
|
+
}>;
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
## Audit history
|
|
715
|
+
|
|
716
|
+
```bash
|
|
717
|
+
lumine admin audit list --json
|
|
718
|
+
lumine admin audit list --run current --json
|
|
719
|
+
lumine admin audit list --run last --actions recommendation.skip --json
|
|
720
|
+
lumine admin audit list --target dailyReflection:99 --full --json
|
|
721
|
+
lumine admin audit list --cursor '<cursor>' --limit 50 --json
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
Lists the operator's own private audit events, newest first, so an agent can
|
|
725
|
+
see what earlier runs did. `--run` accepts `current`, `last`, or a run ID;
|
|
726
|
+
`--target` accepts `<targetType>:<id>`; `--actions` is a comma-separated
|
|
727
|
+
action list. Filters are bound into the cursor exactly like the other list
|
|
728
|
+
cursors. The walk is a bounded descending primary-key traversal over the
|
|
729
|
+
existing operator/run/target audit indexes.
|
|
730
|
+
|
|
731
|
+
Rows are compact by default (identifiers, action, target, result, response
|
|
732
|
+
`status`/`changed`, timestamps, and the request's idempotency key). `--full`
|
|
733
|
+
adds the stored `beforeState`, `afterState`, `responseJson`, and `metadata`
|
|
734
|
+
payloads — the same data the mutation already returned to this operator. The
|
|
735
|
+
private per-attempt fencing token is never returned. Reading audit history
|
|
736
|
+
requires only the `content:read` scope of an active run.
|
|
737
|
+
|
|
738
|
+
```ts
|
|
739
|
+
type AuditEvent = {
|
|
740
|
+
id: number;
|
|
741
|
+
runId: number | null;
|
|
742
|
+
publicActorUserId: number | null;
|
|
743
|
+
sessionKind: string;
|
|
744
|
+
action: string;
|
|
745
|
+
targetType: string | null;
|
|
746
|
+
targetId: number | null;
|
|
747
|
+
requestId: string;
|
|
748
|
+
result: string; // in_progress | completed | failed | partial_failure | bookkeeping_pending
|
|
749
|
+
status: string | null; // response status, e.g. success | already_done
|
|
750
|
+
changed: boolean | null;
|
|
751
|
+
createdAt: number;
|
|
752
|
+
completedAt: number | null;
|
|
753
|
+
// Present only with --full:
|
|
754
|
+
beforeState?: unknown;
|
|
755
|
+
afterState?: unknown;
|
|
756
|
+
responseJson?: unknown;
|
|
757
|
+
metadata?: unknown;
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
type AuditList = Success<{
|
|
761
|
+
events: AuditEvent[];
|
|
762
|
+
pagination: Pagination;
|
|
763
|
+
}>;
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
## Persona-backed comments and replies
|
|
620
767
|
|
|
621
768
|
```bash
|
|
622
769
|
lumine admin daily-run start --identity auto --comment-mode draft --json
|
|
@@ -626,21 +773,44 @@ lumine admin daily-run start --identity ciel --comment-mode post \
|
|
|
626
773
|
--run-key daily:2026-08-06:comments --json
|
|
627
774
|
lumine admin comment draft 123 --identity ciel \
|
|
628
775
|
--idempotency-key comment-123-draft-v1 --json
|
|
776
|
+
lumine admin comment draft dailyReflection:99 --json
|
|
777
|
+
lumine admin comment reply comment:456 --json
|
|
629
778
|
lumine admin comment post --draft-id 77 \
|
|
630
779
|
--idempotency-key comment-123-post-v1 --json
|
|
631
780
|
```
|
|
632
781
|
|
|
782
|
+
A draft targets one of:
|
|
783
|
+
|
|
784
|
+
- `subject:<id>` (or a bare numeric ID) — a top-level comment on the subject;
|
|
785
|
+
- `aiStory:<id>` / `dailyReflection:<id>` — a top-level comment on the
|
|
786
|
+
standalone post;
|
|
787
|
+
- `comment:<id>` — a public reply to that specific comment. `comment reply`
|
|
788
|
+
is the same operation and requires a comment target.
|
|
789
|
+
|
|
790
|
+
A reply's container resolves canonically from the target comment: its subject,
|
|
791
|
+
or its AI Story / Daily Reflection root. Comments under any other root are
|
|
792
|
+
rejected with `CLI_ADMIN_UNSUPPORTED_REPLY_ROOT`. Replies to Zero/Ciel
|
|
793
|
+
comments and to notification comments are rejected with
|
|
794
|
+
`CLI_ADMIN_INVALID_REPLY_TARGET` — the bots never thread with themselves or
|
|
795
|
+
each other, and a human's later reply to a delegated comment still enters the
|
|
796
|
+
existing autonomous comment-assistant pipeline. Published replies carry the
|
|
797
|
+
ordinary thread linkage (thread root and reply-to), and notification fan-out
|
|
798
|
+
uses the normal canonical path.
|
|
799
|
+
|
|
633
800
|
```ts
|
|
634
801
|
type CommentDraft = Success<{
|
|
635
802
|
draft: {
|
|
636
803
|
id: number;
|
|
637
804
|
runId: number;
|
|
638
|
-
|
|
639
|
-
|
|
805
|
+
targetType: "subject" | "comment" | "aiStory" | "dailyReflection";
|
|
806
|
+
targetId: number;
|
|
807
|
+
targetUrl: string;
|
|
808
|
+
subjectId: number | null; // container subject; null for standalone posts
|
|
809
|
+
subjectUrl: string | null;
|
|
640
810
|
publicActorUserId: number;
|
|
641
811
|
commentMode: "draft" | "post";
|
|
642
812
|
personaRevision: string; // SHA-256; raw prompt is never returned
|
|
643
|
-
contextRevision: string; // SHA-256 of canonical
|
|
813
|
+
contextRevision: string; // SHA-256 of canonical container/comments/target
|
|
644
814
|
decision: "draft" | "skip";
|
|
645
815
|
reason: string | null;
|
|
646
816
|
content: string | null;
|
|
@@ -663,24 +833,44 @@ type CommentPost = CommentGet & {
|
|
|
663
833
|
};
|
|
664
834
|
published: {
|
|
665
835
|
commentId: number;
|
|
666
|
-
|
|
667
|
-
|
|
836
|
+
targetType: "subject" | "comment" | "aiStory" | "dailyReflection";
|
|
837
|
+
targetId: number;
|
|
838
|
+
subjectId: number | null;
|
|
839
|
+
subjectUrl: string | null;
|
|
840
|
+
containerUrl: string;
|
|
668
841
|
commentUrl: string;
|
|
669
842
|
};
|
|
670
843
|
};
|
|
671
844
|
};
|
|
672
845
|
```
|
|
673
846
|
|
|
674
|
-
The server loads the canonical subject
|
|
675
|
-
then invokes the existing exact Zero/Ciel
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
847
|
+
The server loads the canonical container (subject or standalone post) and its
|
|
848
|
+
complete visible comment context, then invokes the existing exact Zero/Ciel
|
|
849
|
+
system prompt through the shared response assembler with a mode-specific
|
|
850
|
+
decision policy (comment vs reply). The raw prompt is never returned or
|
|
851
|
+
audited. The model—not regexes or keyword rules—chooses `draft` or `skip`
|
|
852
|
+
under the run policy.
|
|
853
|
+
|
|
854
|
+
Draft IDs are bound to operator, run, public bot, target, comment mode,
|
|
855
|
+
context revision, persona revision, expiry, and idempotency key. The context
|
|
856
|
+
revision covers the container, every visible comment, and the target binding,
|
|
857
|
+
so a thread that changes between draft and publish rejects publication.
|
|
858
|
+
Posting locks the draft and context in the same transaction as the ordinary
|
|
859
|
+
comment insert. Changed context or persona rejects publication and requires
|
|
860
|
+
regeneration. Retries return the already-published comment instead of
|
|
861
|
+
duplicating it. Secret-subject gating applies whenever the container is a
|
|
862
|
+
subject, including replies inside it.
|
|
863
|
+
|
|
864
|
+
Draft idempotency keys are permanent per operator: supplying a key that an
|
|
865
|
+
earlier run (or another target) already used fails rather than resolving to
|
|
866
|
+
the old reservation — normally as the audit layer's
|
|
867
|
+
`CLI_ADMIN_AUDIT_IDENTITY_MISMATCH` (different run) or
|
|
868
|
+
`CLI_ADMIN_IDEMPOTENCY_KEY_MISMATCH` (different target), with
|
|
869
|
+
`CLI_ADMIN_DRAFT_KEY_REUSED` as the draft-table backstop. All three mean the
|
|
870
|
+
same thing: embed the run or date in any caller-supplied draft key and retry
|
|
871
|
+
with a fresh one. Note that the agent's
|
|
872
|
+
own `subject effort set` or `creator set-made-by-poster` between draft and
|
|
873
|
+
post changes the context revision — order those mutations before drafting.
|
|
684
874
|
|
|
685
875
|
## Audit, sockets, and deployment
|
|
686
876
|
|
|
@@ -692,9 +882,9 @@ cookies, passwords, or raw system prompts.
|
|
|
692
882
|
|
|
693
883
|
Retry acquisition and completion are row-locked and fenced by a private
|
|
694
884
|
per-attempt token, so an expired request cannot overwrite a newer retry. A new
|
|
695
|
-
recommendation
|
|
696
|
-
canonical prior-recommender approval and the
|
|
697
|
-
independently retryable.
|
|
885
|
+
recommendation commits atomically (the management bots are exempt from the
|
|
886
|
+
recommendation coin charge); the canonical prior-recommender approval and the
|
|
887
|
+
separate 3-Twinkle reward remain independently retryable.
|
|
698
888
|
|
|
699
889
|
Public content actions use ordinary Twinkle fan-out:
|
|
700
890
|
|
|
@@ -705,9 +895,11 @@ Public content actions use ordinary Twinkle fan-out:
|
|
|
705
895
|
- effort/creator changes emit `edit_content`;
|
|
706
896
|
- Featured changes emit a canonical `home_outdated` refresh.
|
|
707
897
|
|
|
708
|
-
Apply `twinkle-api/scripts/migrations/add-lumine-admin-delegation.sql`
|
|
709
|
-
deploying the API.
|
|
710
|
-
|
|
898
|
+
Apply `twinkle-api/scripts/migrations/add-lumine-admin-delegation.sql` and
|
|
899
|
+
then `add-lumine-admin-comment-targets.sql` before deploying the API. They add
|
|
900
|
+
only focused daily-run, rotation, draft, and audit tables/columns and indexes;
|
|
901
|
+
there are no runtime schema checks. The comment-targets migration backfills
|
|
902
|
+
existing subject drafts into the generalized target columns. The local CLI changes
|
|
711
903
|
are not available to users until a separately authorized npm publication.
|
|
712
904
|
|
|
713
905
|
Legacy aliases such as `subjects list`, `subjects get`, `subjects featured`,
|