@stage5/lumine 0.2.61 → 0.2.63

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/util.js CHANGED
@@ -26,8 +26,21 @@ export function parseBoolean(value, fallback) {
26
26
  return fallback;
27
27
  }
28
28
 
29
- export function sleep(ms) {
30
- return new Promise((resolve) => setTimeout(resolve, ms));
29
+ export function sleep(ms, signal) {
30
+ if (!signal) return new Promise((resolve) => setTimeout(resolve, ms));
31
+ const abortError = signal.reason || new Error("Operation aborted.");
32
+ if (signal.aborted) return Promise.reject(abortError);
33
+ return new Promise((resolve, reject) => {
34
+ const timeout = setTimeout(() => {
35
+ signal.removeEventListener("abort", abort);
36
+ resolve();
37
+ }, ms);
38
+ const abort = () => {
39
+ clearTimeout(timeout);
40
+ reject(signal.reason || abortError);
41
+ };
42
+ signal.addEventListener("abort", abort, { once: true });
43
+ });
31
44
  }
32
45
 
33
46
  export function formatBytes(bytes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stage5/lumine",
3
- "version": "0.2.61",
3
+ "version": "0.2.63",
4
4
  "description": "Command line tools for launching Lumine builds on Twinkle.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,11 +39,19 @@ canonical structured data.
39
39
  described below. The human's normal AI Energy and sponsor path applies;
40
40
  Lumine does not need to remain running.
41
41
 
42
- `auto` selects Zero first when no completed rotation exists, then alternates
43
- after a successfully completed run that performed a mutation. Failed,
44
- abandoned, expired, and read-only runs do not advance rotation. Reusing a run
45
- key returns the original run and identity. One writer-locked identity-state row
46
- serializes concurrent starts.
42
+ The Zero/Ciel shift is assigned by **Asia/Bangkok calendar day, not by run**.
43
+ The schedule is anchored with 2026-08-31 assigned to Zero and alternates by
44
+ elapsed Bangkok dates from there. Every automatic primary, supplemental,
45
+ retry, read-only, or resumed run started on one date uses that date's same
46
+ actor; a skipped date still counts in the alternation. Completing, failing,
47
+ abandoning, or expiring a run never changes the schedule. An explicit
48
+ `--identity zero` or `--identity ciel` is an auditable override for that run
49
+ only: it does not rewrite the scheduled identity. Automatic runs expire at the
50
+ next Bangkok midnight so yesterday's actor cannot continue as today's
51
+ automatic identity. Reusing a live run key still returns the original run and
52
+ identity. `identity use zero|ciel` is the separate, explicit persistent
53
+ override for future starts; it remains in force until `identity use auto`, and
54
+ does not alter the underlying calendar schedule reported by status commands.
47
55
 
48
56
  Comment mode is stored only on the current run:
49
57
 
@@ -245,7 +253,15 @@ posts that most need Zero or Ciel are the ones nobody else answered.
245
253
  mention is what notifies him (`postComment` runs `processMentions` /
246
254
  `postMentions` and emits `new_targeted_upload`), so a bug-report comment
247
255
  without `@mikey` fails its main job. Restate what the child observed; never
248
- promise a fix or a timeline.
256
+ promise a fix or a timeline. This reporting duty does not suspend the acting
257
+ bot's character: the public comment must still sound like Zero or Ciel
258
+ talking naturally to that member, not like an operator, ticket, or incident
259
+ report. Read the full thread first. If the bot already noticed, explained, or
260
+ apologized for the bug, do not post another reply that treats it as a fresh
261
+ discovery or repeats the same acknowledgement. Continue from what the bot
262
+ already said and add only what is missing, such as naturally bringing
263
+ `@mikey` into the conversation. Put the formal defect summary, evidence, and
264
+ review request in the private run escalation.
249
265
  - **Guide users through the website, without waiting to be asked.** A post can
250
266
  show that a child is stuck, confused, or unaware a feature exists without ever
251
267
  containing a question — someone begging for coins who does not know about
@@ -262,17 +278,58 @@ posts that most need Zero or Ciel are the ones nobody else answered.
262
278
  question should normally receive Level 3. Level 3 is the highest delegated
263
279
  setting, and the level tells respondents that substantial, carefully
264
280
  reasoned answers are wanted.
265
- - **Featured still selects for quality**, but when two candidates are close,
266
- prefer the child who has never been featured over the one who has.
267
- - **The live Featured board is Mikey's word.** Do not remove a currently
268
- Featured subject without first showing Mikey the planned removals and
269
- replacements and getting his go-ahead. In the other direction, if a subject
270
- that was Featured or pinned during an earlier run is no longer on
271
- `featured list`, treat that as Mikey having removed it deliberately — never
272
- re-feature it to "restore" the board, and never treat any subject as a
273
- permanent fixture from memory or old run notes. Derive the board fresh from
274
- `featured list` at the start of every run; the only pins that exist are the
275
- ones currently on it.
281
+ - **Ongoing series are participation, not noise.** Daily records, journals,
282
+ logs, recurring updates, and serialized creative work are not spam, filler,
283
+ engagement farming, or duplicates merely because they reuse a title or
284
+ format, or because one installment is concise. Review the series context and
285
+ what the current entry contributes. Never lower effort, skip, withhold a
286
+ recommendation or comment, or propose Featured removal solely because of
287
+ that recurring format or brevity; only an actual duplicate or genuine noise
288
+ is treated as such.
289
+ - **Sincere requests for personal help are Featured material.** Posts asking
290
+ the community for advice about school, friendships, loneliness, or other
291
+ ordinary real-life problems embody Twinkle's purpose; being personal is never
292
+ a reason to suppress or remove them. Receiving meaningful support does not
293
+ make one stale or create a duty to rotate it out; keep judging what the live
294
+ board contributes now, and never use prior recognition as a removal proxy.
295
+ - **Speculative privacy is never an editorial signal.** Do not lower, remove,
296
+ unfeature, or escalate content because it might identify someone, mentions a
297
+ school, city, class, or ordinary location, or invites everyday community
298
+ context. Those possibilities carry zero weight in Featured decisions. An
299
+ actual sensitive disclosure or an author's explicit removal request follows
300
+ the separate concrete-safety path; it does not make the post low-quality.
301
+ - **Featured values participation, continuity, and child voice—not adult
302
+ polish.** Accessible questions that many children can answer and ongoing
303
+ personal series such as records, journals, or recurring updates are strong
304
+ Featured forms. Age, brevity, simplicity, prior recognition, or a modest
305
+ description is not a removal reason. Review the whole subject and its role in
306
+ the community instead of grading its opening text like an essay.
307
+ - **A "new" Featured addition has two non-negotiable eligibility gates.** When
308
+ Mikey asks for new Featured subjects, additions, or replacements, a candidate
309
+ must both (1) have been posted recently and (2) have never appeared on the
310
+ Featured board before. Unless Mikey gives a different recency window,
311
+ "recently" means the preceding seven calendar days; do not widen into older
312
+ inventory merely to fill capacity or produce a longer proposal list. Absence
313
+ from the current `featured list` proves only that a Subject is not Featured
314
+ now — it does not prove that the Subject has never been Featured. Verify
315
+ lifetime Featured history from canonical evidence before recommending or
316
+ adding it. If the available CLI/API cannot prove that history, leave the
317
+ candidate out and report the capability gap instead of guessing. Quality is
318
+ still required after both eligibility gates pass; recent and never-Featured
319
+ does not make filler acceptable.
320
+ - **The live Featured board is Mikey's word.** Do not remove or reorder a
321
+ currently Featured subject without first showing Mikey the planned removals
322
+ and replacements and getting his go-ahead. Additions have standing approval
323
+ when a fresh `featured list` is below its canonical maximum: proactively
324
+ feature genuinely reviewed, editorially strong new subjects without asking
325
+ case by case. This is judgment, not a quota — never add filler merely because
326
+ capacity exists. If a subject that was Featured or pinned during an earlier
327
+ run is no longer on `featured list`, treat that as Mikey having removed it
328
+ deliberately — never re-feature it to "restore" the board, even when space
329
+ is available, and never treat any subject as a permanent fixture from memory
330
+ or old run notes. Derive the board fresh from `featured list` at the start of
331
+ every Featured review or mutation; the only pins that exist are the ones
332
+ currently on it.
276
333
 
277
334
  Sensitive disclosures, active disputes, and anything needing crisis or medical
278
335
  judgment remain out of scope for a bot comment no matter how neglected the post
@@ -286,11 +343,13 @@ happen. **Every run ends with an escalation list**, and it belongs in the run's
286
343
  final report whether or not anyone asks for it.
287
344
 
288
345
  Keep that list narrow enough to be useful. Escalate concrete child-safety,
289
- exploitation, privacy, targeted harassment, or platform/system-abuse risk — not
346
+ exploitation, targeted harassment, or platform/system-abuse risk — not
290
347
  ordinary children experimenting, arguing, making rumors, proposing informal
291
348
  in-site loans or contests, asking where media can be found, or making an
292
349
  unverified ownership claim. Those may merit a normal age-appropriate response,
293
350
  but they are not escalations without credible harmful conduct or a real victim.
351
+ Hypothetical identifiability and ordinary school, city, class, or location
352
+ references are not escalation signals.
294
353
 
295
354
  Escalate, with the canonical `https://www.twin-kle.com/subjects/<id>` or
296
355
  `/comments/<id>` URL, a one-line summary, and why it needs him:
@@ -555,6 +614,8 @@ type DailyRun = {
555
614
  failedAt: number | null;
556
615
  failureReason: string | null;
557
616
  identity: Identity;
617
+ scheduledDay: string; // YYYY-MM-DD in Asia/Bangkok
618
+ scheduledIdentity: Identity;
558
619
  };
559
620
  ```
560
621
 
@@ -582,6 +643,9 @@ type IdentityList = Success<{
582
643
  type IdentityStatus = Success<{
583
644
  preferredIdentity: "auto" | "zero" | "ciel";
584
645
  lastCompletedIdentity: "zero" | "ciel" | null;
646
+ scheduledDay: string;
647
+ scheduledIdentity: Identity;
648
+ scheduleTimeZone: "Asia/Bangkok";
585
649
  activeRun: DailyRun | null;
586
650
  }>;
587
651
 
@@ -633,8 +697,10 @@ type IdentityCandidate = {
633
697
  };
634
698
  ```
635
699
 
636
- `identity use` changes only the preference for a future start. It never changes
637
- an active run or advances rotation.
700
+ `identity use zero|ciel` changes the explicit persistent override for future
701
+ starts; `identity use auto` returns future starts to the Bangkok calendar
702
+ schedule. It never changes an active run, alters the reported scheduled
703
+ identity, or advances rotation.
638
704
 
639
705
  ```bash
640
706
  lumine admin daily-run start --identity auto --comment-mode off --json
@@ -658,6 +724,9 @@ Schemas:
658
724
  ```ts
659
725
  type DailyRunStart = Success<{
660
726
  run: DailyRun;
727
+ scheduledDay: string;
728
+ scheduledIdentity: Identity;
729
+ scheduleTimeZone: "Asia/Bangkok";
661
730
  carryoverTodos: CarryoverTodos;
662
731
  }>;
663
732
  type DailyRunStatus = Success<{
@@ -666,7 +735,7 @@ type DailyRunStatus = Success<{
666
735
  }>;
667
736
  type DailyRunComplete = Success<{
668
737
  run: DailyRun;
669
- rotationAdvanced: boolean;
738
+ rotationAdvanced: false; // legacy field; calendar schedules never advance by run
670
739
  }>;
671
740
  type DailyRunFail = DailyRunComplete;
672
741
  ```
@@ -715,6 +784,18 @@ the current active run. Queue coverage is written automatically only after an
715
784
  `--all` traversal reaches canonical exhaustion; an interrupted scan remains in
716
785
  its local checkpoint and cannot be misreported as complete.
717
786
 
787
+ **Every agent-authored final management report includes a `Featured rotation`
788
+ section.** Base it on a fresh `featured list`. When capacity exists, make and
789
+ report strong additions during the run under the standing approval above; do
790
+ not defer them as proposals. Then name each current Subject proposed for
791
+ removal with its canonical URL and a concrete editorial reason, followed by
792
+ any replacement that would require that removal. Every proposed or completed
793
+ addition described as new must include its posting date and canonical evidence
794
+ that it has never been Featured; omit it when either gate is unverified. Never
795
+ omit the section; when no removal or reorder is honestly warranted, say `None`
796
+ and explain why. Removing or reordering pins remains a proposal until Mikey
797
+ gives his go-ahead.
798
+
718
799
  Creating an escalation belongs to the active run; acknowledging, annotating,
719
800
  resolving, or reopening it does not. Use the run-independent `escalation`
720
801
  commands after Mikey responds instead of starting a follow-up delegated run.
@@ -1089,6 +1170,7 @@ type CommentGet = Success<{
1089
1170
  id: number;
1090
1171
  url: string;
1091
1172
  title: string | null;
1173
+ author: Author;
1092
1174
  secretShown: boolean;
1093
1175
  } | null;
1094
1176
  }>;
@@ -1953,8 +2035,9 @@ part of the feature contract.
1953
2035
  Starting 2026-08-27, every website-management run must also check AWS Cost
1954
2036
  Explorer and include the current calendar month's expected AWS bill in
1955
2037
  **"Insights for Mikey"**. This is an account-level infrastructure cost check,
1956
- not the `aiSpending` application-cost section above; never substitute one for
1957
- the other or combine their totals.
2038
+ not the `aiSpending` application-cost section above. Never substitute one for
2039
+ the other. Report each independently, then combine them only under the aligned-
2040
+ total rules below.
1958
2041
 
1959
2042
  First verify the Twinkle AWS principal exactly as required by the repository
1960
2043
  agent guide. Use profile `mikey-iam`, pass an explicit region on every command,
@@ -1975,6 +2058,10 @@ aws ce get-cost-and-usage --profile mikey-iam --region us-east-1 \
1975
2058
  --time-period Start=<month-start-YYYY-MM-01>,End=<today-UTC> \
1976
2059
  --granularity MONTHLY --metrics UnblendedCost
1977
2060
 
2061
+ aws ce get-cost-and-usage --profile mikey-iam --region us-east-1 \
2062
+ --time-period Start=<previous-month-start>,End=<month-start-YYYY-MM-01> \
2063
+ --granularity MONTHLY --metrics UnblendedCost
2064
+
1978
2065
  aws ce get-cost-and-usage --profile mikey-iam --region us-east-1 \
1979
2066
  --time-period Start=<month-start-YYYY-MM-01>,End=<today-UTC> \
1980
2067
  --granularity MONTHLY --metrics UnblendedCost \
@@ -2003,12 +2090,52 @@ rather than a final invoice because reporting lags and later credits, refunds,
2003
2090
  taxes, or adjustments can change the bill. If either the forecast or MTD query
2004
2091
  is unavailable, report the available component and say why a complete
2005
2092
  full-month expectation is unavailable instead of extrapolating it locally. A
2006
- previous closed month may be quoted for context when the difference is
2007
- material, but it is not a replacement for the current-month expectation.
2093
+ previous closed calendar-month query is mandatory: report its exact total and
2094
+ `Estimated` state, then compare the expected current full-calendar-month mean
2095
+ against it with both the dollar delta and percentage change. Never compare an
2096
+ incomplete current-month MTD total directly with a closed full month; if either
2097
+ the current full-month expectation or previous closed-month total is
2098
+ unavailable, say that the month-over-month comparison is unavailable rather
2099
+ than manufacturing one. A zero previous-month total has no meaningful
2100
+ percentage change. The previous month is context, not a replacement for the
2101
+ current-month expectation.
2102
+
2008
2103
  For the media watch, separately identify AWS Elemental MediaConvert and Amazon
2009
2104
  Interactive Video Service rows when present. Also report Amazon S3 as shared
2010
2105
  storage context, without attributing the whole S3 row to Lumine media.
2011
2106
 
2107
+ ### Combined application AI and AWS cost (standing duty, every run)
2108
+
2109
+ Every website-management report must also give Mikey one **Combined AI + AWS
2110
+ tracked operating cost** view. This is a mixed-source estimate, not an invoice
2111
+ or a claim to cover every company expense. Keep the independent AI and AWS
2112
+ figures visible so the total remains auditable.
2113
+
2114
+ - Add application-AI completed-day MTD to AWS completed-day MTD only when their
2115
+ currency and inclusive UTC through-date match. Report the aligned boundary.
2116
+ Never include `inProgressDay` or compare this incomplete MTD sum directly
2117
+ with a closed full month.
2118
+ - Add the previous closed AI-month estimate to the previous closed AWS
2119
+ unblended-cost total and report the resulting previous closed-month combined
2120
+ total.
2121
+ - For the expected current full month, add the AWS full-month expectation to
2122
+ `allCompletedDaysPace` as the headline combined scenario. When
2123
+ `recentSevenCompletedDaysPace` exists, add it as a clearly labeled run-rate
2124
+ sensitivity, not a provider confidence interval. Compare each reported
2125
+ combined scenario with the previous closed-month combined total using both
2126
+ dollar and percentage change.
2127
+ - Carry the AWS 80% lower and upper bounds through a combined scenario by
2128
+ adding the same AI projection to both bounds. Do not describe the difference
2129
+ between the two AI run-rate scenarios as a confidence interval.
2130
+ - Do not add Media Energy or AWS service rows again: MediaConvert, IVS, S3, and
2131
+ other AWS costs are already inside Cost Explorer's account total. If the
2132
+ application AI ledger ever includes a provider billed inside the AWS total,
2133
+ identify and remove the overlap before combining; otherwise report the
2134
+ combined figure as unavailable rather than double-counting.
2135
+ - If currency, calendar boundary, a required component, or overlap attribution
2136
+ cannot be reconciled, report the available components and explicitly mark the
2137
+ affected combined total or comparison unavailable. Never manufacture one.
2138
+
2012
2139
  Ten sections (Mikey's chosen cut 2026-08-10; behavioral-insight and
2013
2140
  farm-signal sections added that day; AI Card summon watch added 2026-08-24):
2014
2141
 
@@ -2420,8 +2547,29 @@ type InsightsBrief = Success<{
2420
2547
  }>;
2421
2548
  ```
2422
2549
 
2550
+ ### Narrow comment-correction sessions
2551
+
2552
+ Correcting one existing bot comment does not require opening a daily run:
2553
+
2554
+ ```bash
2555
+ lumine admin correction start <commentId> --json
2556
+ lumine admin comments get <commentId> --json
2557
+ lumine admin comment edit <commentId> --file corrected.md --json
2558
+ lumine admin correction complete <sessionId> --json
2559
+ ```
2560
+
2561
+ The server derives Zero or Ciel from the comment's actual author; the caller
2562
+ cannot choose or override that identity. The authorization lasts ten minutes,
2563
+ is bound to that exact comment, permits only reading that target and editing
2564
+ it, and never runs daily duties, changes the Bangkok calendar assignment, or
2565
+ contributes to a daily-run mutation count. A correction cannot target a human
2566
+ comment, notification record, deleted comment, or Build thread. Build comments
2567
+ still require a fresh version-bound correction reply after genuinely reviewing
2568
+ the published app. Starting a newer correction supersedes an older active one.
2569
+ Finish it explicitly after the canonical edit is confirmed.
2570
+
2423
2571
  **Editing the bot's own comments.** `comment edit <commentId> --file
2424
- <comment.md>` replaces the text of a comment the ACTING bot itself authored —
2572
+ <comment.md>` replaces the text of a comment the acting bot itself authored —
2425
2573
  for correcting a factual error, an unfulfillable claim, or outdated guidance
2426
2574
  in Zero/Ciel's own words. It is deliberately not a moderation verb: comments
2427
2575
  by the other bot, by any human, and hidden notification records are all
@@ -2431,12 +2579,14 @@ composed-comment rules (plain UTF-8, 10,000-character limit, truth about what
2431
2579
  the session actually did) and publishes through the website's canonical
2432
2580
  comment-edit pipeline — mentions are reprocessed (a newly added `@mikey`
2433
2581
  notifies him), and Earn-candidate projections resync. Submitting identical
2434
- text returns `already_done`. Requires the `comment:post` scope of a
2435
- comment-mode `post` run, and is audited as `comment.edit` with the previous
2436
- content in `beforeState` and `data.edit.previousContent`. Edit sparingly:
2582
+ text returns `already_done`. It requires either the exact active correction
2583
+ session above or the `comment:post` scope of a comment-mode `post` run, and is
2584
+ audited as `comment.edit` with the previous content in `beforeState` and
2585
+ `data.edit.previousContent`. Edit sparingly:
2437
2586
  kids may have already read the original, so a comment that changed meaning
2438
2587
  (not just wording) usually deserves a follow-up reply instead of a silent
2439
- rewrite.
2588
+ rewrite. Inside a normal daily run it still requires that run's `comment:post`
2589
+ scope; for a one-comment repair, use the narrower correction session above.
2440
2590
 
2441
2591
  ## Direct bot chat messages
2442
2592
 
@@ -2593,6 +2743,33 @@ from memory:
2593
2743
  decisions are yours to make and record with `post skip` or in the run
2594
2744
  report).
2595
2745
 
2746
+ Persona and conversational state are continuous across the whole thread,
2747
+ including acknowledgements, corrections, bug reports, `@mikey` notifications,
2748
+ and other reporting duties. The acting bot must remember what it already said:
2749
+ do not reintroduce a conclusion, apology, explanation, question, or offer as if
2750
+ the earlier bot comment did not exist. A follow-up should advance the existing
2751
+ conversation and make its relationship to the prior reply natural and clear.
2752
+ Accuracy and escalation requirements never authorize a sudden formal admin
2753
+ voice. Before posting, read the full thread, identify the acting bot's existing
2754
+ claims and commitments, and preserve the canonical character plus the
2755
+ established conversational register where they agree: phrasing,
2756
+ capitalization, warmth, humor, and emoji restraint should feel like the same
2757
+ Zero or Ciel continuing the conversation. Do not mechanically copy typos,
2758
+ mistakes, unsafe behavior, or a voice that conflicts with the canonical
2759
+ persona. Keep the two surfaces distinct: the public comment is an in-character
2760
+ continuation for the member, while `daily-run escalation add` and the final
2761
+ management report carry the concise operator-facing diagnosis and evidence. A
2762
+ comment that is factually correct but ignores the bot's earlier reply, repeats
2763
+ it as new, or reads like a support ticket or management audit fails this
2764
+ requirement.
2765
+
2766
+ Keep participant ownership exact while continuing that thread. The
2767
+ `subject.author` (or root post's `author`) owns the topic, subject, post, or
2768
+ project. A selected comment's `author` owns only that comment. Addressing a
2769
+ commenter does not make the root content theirs: never call the root topic,
2770
+ subject, post, or project “yours” unless that participant is also its canonical
2771
+ author. Read both author fields before composing a reply.
2772
+
2596
2773
  **Lumine Build apps and app posts are composed-only, and only after actually looking
2597
2774
  (Mikey's direction, 2026-08-10).** When a post is about a Build app — the
2598
2775
  author shares their app, announces an update, or asks for feedback on their