counterparts 0.3.5 → 0.3.6
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/CHANGELOG.md +89 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +48 -30
- package/src/adapters/claude-code/NOTES.md +25 -0
- package/src/adapters/claude-code/doctor.ts +81 -25
- package/src/adapters/claude-code/hooks.ts +24 -294
- package/src/adapters/claude-code/index.ts +0 -2
- package/src/adapters/cli/commands.ts +51 -16
- package/src/adapters/cli/dream-core.ts +35 -8
- package/src/adapters/cli/help.ts +7 -6
- package/src/adapters/cli/self-page.ts +5 -2
- package/src/adapters/dashboard/activity.ts +18 -5
- package/src/adapters/dashboard/registries.ts +1 -1
- package/src/adapters/dashboard/stories.ts +3 -1
- package/src/adapters/dashboard/web/README.md +58 -58
- package/src/adapters/dashboard/web/app.html +1 -4
- package/src/adapters/dashboard/web/app.js +3 -7
- package/src/adapters/dashboard/web/mechanisms/prospective/panel.js +11 -2
- package/src/adapters/dashboard/web/mechanisms/salience/panel.js +16 -4
- package/src/adapters/dashboard/web/narrate.ts +25 -6
- package/src/adapters/dashboard/web/pages/health/health.css +137 -0
- package/src/adapters/dashboard/web/pages/health/index.js +23 -12
- package/src/adapters/dashboard/web/pages/health/sections/archive.js +5 -2
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +31 -24
- package/src/adapters/dashboard/web/pages/{home/sections/explorer.js → health/sections/mechanisms.js} +30 -76
- package/src/adapters/dashboard/web/pages/home/brain.js +17 -36
- package/src/adapters/dashboard/web/pages/home/go.js +7 -0
- package/src/adapters/dashboard/web/pages/home/home.css +53 -204
- package/src/adapters/dashboard/web/pages/home/index.js +47 -58
- package/src/adapters/dashboard/web/pages/home/sections/brain.js +84 -0
- package/src/adapters/dashboard/web/pages/home/sections/feel.js +37 -0
- package/src/adapters/dashboard/web/pages/home/sections/hero.js +43 -20
- package/src/adapters/dashboard/web/pages/home/sections/map.js +25 -0
- package/src/adapters/dashboard/web/pages/home/sections/today.js +41 -0
- package/src/adapters/dashboard/web/pages/memories/index.js +9 -3
- package/src/adapters/dashboard/web/pages/memories/sections/feel.js +33 -14
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +9 -4
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +9 -1
- package/src/adapters/dashboard/web/pages/self/sections/dreams.js +4 -1
- package/src/adapters/dashboard/web/pages/self/sections/map.js +75 -19
- package/src/adapters/dashboard/web/pages/self/sections/page.js +2 -2
- package/src/adapters/dashboard/web/pages/self/sections/traits.js +10 -9
- package/src/adapters/dashboard/web/pages/self/self.css +5 -0
- package/src/adapters/dashboard/web/shared/base.css +0 -1
- package/src/adapters/dashboard/web/shared/doctor.js +68 -0
- package/src/adapters/dashboard/web/shared/layout.css +0 -1
- package/src/adapters/dashboard/web/shared/widgets/feed.js +13 -43
- package/src/adapters/dashboard/web/shell/pulse.js +1 -16
- package/src/adapters/dashboard/web/views/activity.ts +10 -4
- package/src/adapters/dashboard/web/views/archive-words.ts +6 -0
- package/src/adapters/dashboard/web/views/dreams.ts +8 -5
- package/src/adapters/dashboard/web/views/flow-view.ts +9 -5
- package/src/adapters/dashboard/web/views/health.ts +13 -4
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +24 -11
- package/src/adapters/dashboard/web/views/memories.ts +33 -22
- package/src/adapters/dashboard/web/views/memory.ts +3 -1
- package/src/adapters/dashboard/web/views/mind.ts +19 -12
- package/src/adapters/dashboard/web/views/overview.ts +56 -91
- package/src/adapters/dashboard/web/views/search.ts +13 -5
- package/src/adapters/dashboard/web/views/today.ts +181 -0
- package/src/adapters/dashboard/web/views/traits.ts +117 -18
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +9 -10
- package/src/adapters/mcp/server.ts +232 -33
- package/src/adapters/mcp/tools.ts +52 -28
- package/src/adapters/sessions.ts +5 -0
- package/src/core/counterpart.ts +141 -17
- package/src/core/dream/CONTRACT.md +106 -37
- package/src/core/dream/NOTES.md +159 -0
- package/src/core/dream/index.ts +623 -147
- package/src/core/dream/reflect.ts +799 -219
- package/src/core/dream/tunables.ts +33 -4
- package/src/core/remember/owes.ts +4 -1
- package/src/core/schemas/index.ts +8 -1
- package/src/core/self/CONTRACT.md +33 -18
- package/src/core/self/NOTES.md +26 -0
- package/src/core/self/index.ts +22 -3
- package/src/core/self/journal-file.ts +5 -2
- package/src/core/self/page.ts +60 -30
- package/src/core/self/writer.ts +114 -19
- package/src/core/store/NOTES.md +3 -1
- package/src/core/store/errors.ts +4 -3
- package/src/core/store/feelings.ts +143 -22
- package/src/core/store/index.ts +74 -14
- package/src/core/store/traits.ts +24 -6
- package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +0 -34
- package/src/adapters/dashboard/web/pages/home/sections/tiles.js +0 -62
- package/src/adapters/dashboard/web/pages/home/sections/tonight.js +0 -74
- package/src/adapters/dashboard/web/pages/home/sections/written.js +0 -76
- package/src/adapters/dashboard/web/views/tonight.ts +0 -158
- package/src/adapters/dashboard/web/views/written-returned.ts +0 -93
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.6 — 2026-09-28
|
|
4
|
+
|
|
5
|
+
The nightly run: once a day, Claude writes its page, dreams and reflects in one
|
|
6
|
+
background run, and starts it on its own. **The store's format does not change** (it
|
|
7
|
+
stays v9), so nothing is copied or upgraded. Close every session before installing
|
|
8
|
+
anyway: a session left open keeps the old memory server while the hooks switch to the
|
|
9
|
+
new code at once, and the new dream start needs both. Run `/mcp` → Reconnect in any
|
|
10
|
+
you missed.
|
|
11
|
+
|
|
12
|
+
The nightly run.
|
|
13
|
+
|
|
14
|
+
- **One background run, once a calendar day: the page writer, then the dream, then
|
|
15
|
+
the reflection.** The first prompt of a new day tells Claude to start it, when at
|
|
16
|
+
least 3 memories are new since the last dream. Claude hands it to one background
|
|
17
|
+
agent and tells you one line: "Dreaming in the background (a few minutes). Say 'no
|
|
18
|
+
dreams' anytime to turn it off." With fewer than 3 new memories nothing runs, and
|
|
19
|
+
they carry over to the next day.
|
|
20
|
+
- **Dreaming has a setting: auto, ask or off.** `auto` is the default: the run starts
|
|
21
|
+
on its own and says so. `ask` asks you first, as 0.3.5 did. `off` asks nothing.
|
|
22
|
+
Say "no dreams" in a session, or run `counterparts dream --setting off`; turn it
|
|
23
|
+
back on the same way (`--setting auto`). `counterparts dream` and doctor's Dreaming
|
|
24
|
+
line say which it is.
|
|
25
|
+
- **The page writer is back in the run.** It no longer waits for room in the session
|
|
26
|
+
start, which is why it had stopped. It is handed the page whole and the day it
|
|
27
|
+
reads, as the first step of the run.
|
|
28
|
+
- **Who wrote each version of the page.** A version the reflection wrote is now
|
|
29
|
+
labelled "reflection", apart from the writer's. Both may write the page on the same
|
|
30
|
+
night, and every version is kept. `counterparts self-page --versions` and the
|
|
31
|
+
dashboard's Self tab say which.
|
|
32
|
+
- **A dream that was cut off picks up where it stopped.** If a dream began, changed
|
|
33
|
+
something and then went quiet for 30 minutes (its session closed, say), the next
|
|
34
|
+
session starts the run again and the dream resumes: what it already did stands. A
|
|
35
|
+
dream that began and changed nothing is closed and a fresh one starts. A run that
|
|
36
|
+
dreamed but was cut off before it reflected finishes only the reflection. At most
|
|
37
|
+
twice a day.
|
|
38
|
+
- **"Dreamed today" and "reflected today" are calendar days**, not days of use.
|
|
39
|
+
- **The reflection sees what the dream saw**, every memory the dream was shown and
|
|
40
|
+
what it made, and can cite them. It gets the self page whole. When all of that is
|
|
41
|
+
too long for one answer, it comes in parts ("part 1 of 3"), and nothing is cut.
|
|
42
|
+
- **Page sections.** The self page's own headings ("Us", "How I work", anything) are
|
|
43
|
+
read as sections, not only Core and Lately. The dashboard's Self tab, the `self_page`
|
|
44
|
+
tool and the CLI list every one.
|
|
45
|
+
- Doctor no longer marks the page writer amber just because a night is owed. It is
|
|
46
|
+
amber only when nightly runs went on for days without the writer, or it failed.
|
|
47
|
+
|
|
48
|
+
Fewer refusals.
|
|
49
|
+
|
|
50
|
+
- **Dreams and reflections are refused less, and repaired more.** An over-long or
|
|
51
|
+
two-part feeling ("steadied: after the long week") is split: the first word is the
|
|
52
|
+
feeling, the rest goes to what carried it. Texts over their limit are kept to the
|
|
53
|
+
limit and the result says so; the limits for a morning share, a reflection's entry,
|
|
54
|
+
a dream's journal and a merged memory are higher. Many refusals that protected
|
|
55
|
+
nothing now write, with a note. The ones that stay (dream words never become lived
|
|
56
|
+
memory, a confidential memory's words stay off the page, the page cites real
|
|
57
|
+
memories) now say why, with the words or the id that tripped them.
|
|
58
|
+
- **The self page may quote a lived memory a dream also quoted.** The old check
|
|
59
|
+
refused it.
|
|
60
|
+
- **A reflection can finish a second time the same day**, to supply what the first
|
|
61
|
+
finish left out or had refused: the page, the share, feelings, what a memory is
|
|
62
|
+
about, traits. It never writes a second entry. A share already told can't be
|
|
63
|
+
replaced. The same feeling sent twice is recorded once.
|
|
64
|
+
- The instructions Claude reads now say which feeling field is which, before it
|
|
65
|
+
writes.
|
|
66
|
+
|
|
67
|
+
Seeing it.
|
|
68
|
+
|
|
69
|
+
- **Newest first.** When a record held more events than a view read, several views
|
|
70
|
+
kept the oldest and called them the newest: the dashboard's feed, a memory's days
|
|
71
|
+
of use, Health's heatmap (today read empty), the flow view, contested beliefs, the
|
|
72
|
+
page's version reasons, and a few doctor counts. They read the newest now.
|
|
73
|
+
- **"Of N".** A list that is cut says so: search says "the closest 25 of N matches",
|
|
74
|
+
Health's archive "the newest 200 of N", dreams "the newest 12 of N".
|
|
75
|
+
`counterparts dream --list --all` lists every dream.
|
|
76
|
+
|
|
77
|
+
**The dashboard's Home tab, round 4.** Home now holds the best pictures from the other
|
|
78
|
+
tabs, each a way in. A headline (the day, your name, how many memories, how many new
|
|
79
|
+
today) with a health dot that links to Health. The brain beside **Today**: a few plain
|
|
80
|
+
lines about what happened to memory today, each opening that thing. **How it feels**
|
|
81
|
+
(the feelings radar) and **Around the core** (the Self tab's map). Gone from Home: the
|
|
82
|
+
four tiles, the written/came-back strip, the Tonight box and the live feed. The
|
|
83
|
+
mechanism pills and "how it works" moved to the end of Health.
|
|
84
|
+
|
|
85
|
+
**Other dashboard fixes.** "How I act" puts the faint week-ago mark where it really
|
|
86
|
+
stood a week ago, counting memories archived since, and fits a phone. Day counts are
|
|
87
|
+
whole ("14 days of use", not "14.00"). Health names archived memories in words
|
|
88
|
+
("merged in a dream", not "dream-merge"), and says its memory count leaves out the
|
|
89
|
+
cards for people and projects. Home's chapter count matches Self's. The Self map's
|
|
90
|
+
ready dots no longer sit on top of each other.
|
|
91
|
+
|
|
3
92
|
## 0.3.5 — 2026-09-27
|
|
4
93
|
|
|
5
94
|
Claude reflects after a dream, tells you about it in the morning, and rewrites its self
|
package/package.json
CHANGED
|
@@ -563,22 +563,42 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
563
563
|
back immediately. Doctor prints these steps as the remedy on any Snapshot
|
|
564
564
|
finding that is not green.
|
|
565
565
|
|
|
566
|
-
### The nightly page writer
|
|
567
|
-
|
|
568
|
-
**[M]
|
|
569
|
-
|
|
570
|
-
the
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
566
|
+
### The nightly run, and the page writer inside it (2026-09-28 — working defaults, held lightly)
|
|
567
|
+
|
|
568
|
+
**[M] Once per local calendar day, the first session's line starts the nightly run.** On the
|
|
569
|
+
first prompt of a calendar day (`hooks.ts#dreamLines`, UserPromptSubmit), when at least three
|
|
570
|
+
memories are new since the last dream, the line tells the model to call the dream tool's
|
|
571
|
+
`launch` and hand the prompt to ONE background agent, then tell the owner in one line:
|
|
572
|
+
"Dreaming in the background (a few minutes). Say 'no dreams' anytime to turn it off." The
|
|
573
|
+
run is, in order (`DREAM_TUNABLES.NIGHT_ORDER`, the owner's call): the page writer, the dream,
|
|
574
|
+
the reflection — the writer first so it reads yesterday before any merge archives an
|
|
575
|
+
original, survives a session cut off mid-run, and the dream and the reflection see the fresh
|
|
576
|
+
page.
|
|
577
|
+
Fewer than three new: nothing runs, and they carry over (new = since the last dream). The
|
|
578
|
+
owner's setting decides the line — `auto` (the default) starts the run, `ask` asks first as
|
|
579
|
+
it did from 2026-09-26, `off` says nothing — kept in the store's meta, set by the dream
|
|
580
|
+
tool's `setting` phase ("no dreams") or `counterparts dream --setting`, shown by doctor. The
|
|
581
|
+
line is claimed once a day across sessions (`dream_asks`), and again only for a run left
|
|
582
|
+
behind (a dream begun and quiet for 30 minutes, or — `auto` — a launch no dream followed),
|
|
583
|
+
at most twice a day.
|
|
584
|
+
|
|
585
|
+
**[M] The writer moved out of the wake and into the run (2026-09-28).** The SessionStart ask
|
|
586
|
+
that handed the first session of a day the day just gone (S2's session mode, 2026-09-20) is
|
|
587
|
+
RETIRED, and with it its deferral (`no-room`), its contest with the first-launch question
|
|
588
|
+
for the ask field, and the registry mark it wrote. The dream tool's `writer` phase — the
|
|
589
|
+
run's first call — writes the night's claim (the ordinary `asked` row, `about` = yesterday's
|
|
590
|
+
local date, carrying the SESSION and the run) and hands the writer its day through a tool
|
|
591
|
+
result, the page whole: no injection ceiling, so nothing is deferred for room.
|
|
592
|
+
The MCP server labels a `self_page` write `by: "writer"` when the write NAMES a session
|
|
593
|
+
that holds that open claim (`self/writer.ts#nightClaimFor`) — not the session the server is
|
|
594
|
+
bound to, so the owner's own page edit in the run's session stays an ordinary amendment;
|
|
595
|
+
and when the run moves past the writer without a write, its next phase answers the night
|
|
596
|
+
`nothing-to-say`. The registry mark and host mode's environment pin are still read. The wake's `injection`, `bytes` and `sentinel` are untouched by any of it.
|
|
597
|
+
|
|
598
|
+
**[M] Host mode (not the default; left in place) starts a windowless session of the self,
|
|
599
|
+
and reads the outcome from the store.** With `pageWriter.mode: host` the nightly run claims
|
|
600
|
+
nothing for the writer (its `writer` phase says so) and the worker's child writes instead.
|
|
601
|
+
`claude -p`, so the ordinary SessionStart hook fires inside the child and the
|
|
582
602
|
writer wakes with the wake; exactly one pre-approved tool, the page's. The plan is pure and
|
|
583
603
|
decides everything; the starter is six lines. The package's own values go onto the child's
|
|
584
604
|
environment LAST (§2.13), and `COUNTERPARTS_SESSION` / `COUNTERPARTS_SCOPE` are REMOVED
|
|
@@ -588,24 +608,22 @@ as a pinned DATE (`COUNTERPARTS_PAGE_WRITER`), because a windowless child's sess
|
|
|
588
608
|
minted by the host after the launcher is gone. **The child's stdout is never parsed into a
|
|
589
609
|
verdict**: what the run did is read from the page's version chain and from the row the tool
|
|
590
610
|
left, and the exit code decides only between "nothing to say" and "could not run". The
|
|
591
|
-
child
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
shortest shape; the delivered one is longer), and re-composed once against the room the
|
|
597
|
-
first attempt proved was really there. A block that will not fit, or that can carry none of
|
|
598
|
-
the day, is DEFERRED — and the deferral leaves a durable `skipped` row, deduped one per
|
|
599
|
-
night per reason, which claims nothing and can never close a night. The first-launch scope
|
|
600
|
-
question still wins the field, but only once per night: on a blank store it is exactly what
|
|
601
|
-
is pending on nights 1–3, and an unanswered one used to starve the writer for ever.
|
|
611
|
+
child is told nothing on its prompts (`HookInput.pageWriter`): no dream line, no reminders.
|
|
612
|
+
|
|
613
|
+
(Retired with the SessionStart ask, 2026-09-28: the measured-not-predicted sizing against the
|
|
614
|
+
host's ceiling, the durable `skipped` deferral rows, and the first-launch question's
|
|
615
|
+
once-per-night patience. `skipped` rows written before still read as they always did.)
|
|
602
616
|
|
|
603
617
|
**[M] It never costs anything else.** The writer runs last in the detached worker, inside
|
|
604
618
|
the same `finally` as the snapshot, so a day whose sweep broke is still a day that gets
|
|
605
619
|
written about; it never throws; and a failure never fails a wake, a boundary or a session.
|
|
606
|
-
Doctor's `Page writer` line is GREEN when it has never run on a store with no yesterday
|
|
607
|
-
GREEN on a night that had nothing to say,
|
|
608
|
-
|
|
620
|
+
Doctor's `Page writer` line is GREEN when it has never run on a store with no yesterday,
|
|
621
|
+
GREEN on a night that had nothing to say, GREEN when it is off (a deliberate choice; this
|
|
622
|
+
page used to say amber while a page stands, which the code has not done since the S2 review
|
|
623
|
+
— the words follow the code as of 2026-09-28), AMBER on a failure, a refusal, an unreadable
|
|
624
|
+
`pageWriter` block, or — in session mode — a night owed for days while nightly runs went on
|
|
625
|
+
without it, and never RED. A night owed because no run started (fewer than three new
|
|
626
|
+
memories, dreaming off or declined) is green: the writer runs inside the nightly run now.
|
|
609
627
|
|
|
610
628
|
**[M] The child gets the day on STDIN and a stance this package chose.** The instruction is
|
|
611
629
|
not in `argv`, where `ps` shows it to every process on the machine, and
|
|
@@ -1634,3 +1634,28 @@ reflection rewrote the page it finds the night claimed and stands down.
|
|
|
1634
1634
|
|
|
1635
1635
|
- **2026-09-27, owner ruling D3 on #256:** `openAdapter` passes `pageWriter.mode` to
|
|
1636
1636
|
`Counterpart.open`, so `off` stops the reflection's page write in the hooks' process too.
|
|
1637
|
+
|
|
1638
|
+
## 2026-09-28 — the nightly run starts on its own; the writer's ask leaves the wake
|
|
1639
|
+
|
|
1640
|
+
Working defaults, held lightly. The dream line (`dreamLines`, UserPromptSubmit) follows
|
|
1641
|
+
the owner's dreaming setting: `auto` (the default) tells the model to call the dream
|
|
1642
|
+
tool's `launch` now, hand the prompt to one background agent — the page writer, the
|
|
1643
|
+
dream, the reflection — and tell the owner in one line how to say "no dreams"; `ask`
|
|
1644
|
+
keeps the 09-26 ask; `off` says nothing. The line claims the day once across sessions
|
|
1645
|
+
and again only for a run left behind (dream CONTRACT §5.1).
|
|
1646
|
+
|
|
1647
|
+
The SessionStart page-writer ask is RETIRED (`deliverPageWriterAsk`,
|
|
1648
|
+
`writerStarvedByScope`, `noteWriterDeferred`, `SCOPE_PATIENCE_DEFERRALS`,
|
|
1649
|
+
`ASK_SEPARATOR_BYTES`): the writer gets its day through the dream tool's `writer`
|
|
1650
|
+
phase, where no injection ceiling applies, so `no-room` cannot happen and the
|
|
1651
|
+
first-launch scope question has the ask field to itself. The registry mark
|
|
1652
|
+
(`pageWriterFor`) is still read by the MCP door, and nothing writes it now. Host mode
|
|
1653
|
+
is left in place, not the default.
|
|
1654
|
+
|
|
1655
|
+
Doctor's Page writer line: a night owed because no run started (fewer than three new
|
|
1656
|
+
memories, dreaming off or declined) is GREEN — the ordinary state of a quiet week; it is
|
|
1657
|
+
amber only when nightly runs went on for days without the writer, or on a failure, a
|
|
1658
|
+
refusal or an unreadable block. The fix text no longer names `injectionBudgetBytes` or
|
|
1659
|
+
host mode. The CONTRACT's old "amber while off and a page stands" was drift — the code
|
|
1660
|
+
had said green since the S2 review — and the CONTRACT now says what the code does.
|
|
1661
|
+
Doctor's Dreaming line leads with the setting.
|
|
@@ -68,6 +68,8 @@ import type { EventRow } from "../../core/store/index.js";
|
|
|
68
68
|
// The ask allowance the amber hint names, read rather than retyped: a number in
|
|
69
69
|
// a diagnostic's prose is a number that goes stale silently.
|
|
70
70
|
import { SELF_TUNABLES } from "../../core/self/tunables.js";
|
|
71
|
+
import { dreamingSetting } from "../../core/dream/index.js";
|
|
72
|
+
import type { DreamingSetting } from "../../core/dream/index.js";
|
|
71
73
|
// The page's own reader, so this line cannot drift from what the wake prints.
|
|
72
74
|
import { clearedMarker, findPageRow, readSelfPage } from "../../core/self/page.js";
|
|
73
75
|
import {
|
|
@@ -170,9 +172,10 @@ export const SESSION_NOTICE_BUDGET_MS = 150;
|
|
|
170
172
|
/**
|
|
171
173
|
* How many lived days back the newest-row search widens through.
|
|
172
174
|
*
|
|
173
|
-
* `Store.eventLog`
|
|
174
|
-
* this name"
|
|
175
|
-
*
|
|
175
|
+
* Written when `Store.eventLog` read only ASCENDING with a LIMIT, so "the
|
|
176
|
+
* newest row of this name" was not a query it offered. Since #272 it is
|
|
177
|
+
* (`order: "desc", limit: 1`); this ladder predates that and is left as it
|
|
178
|
+
* is, because it is exact either way: a window whose result is
|
|
176
179
|
* SHORTER than the limit was not truncated, so its last row is provably the
|
|
177
180
|
* newest in that window. The ladder starts at today so the common case reads
|
|
178
181
|
* the fewest rows, and widens only when a window is empty.
|
|
@@ -1712,6 +1715,7 @@ function rowsInWindow(
|
|
|
1712
1715
|
const all = store.eventLog({
|
|
1713
1716
|
name,
|
|
1714
1717
|
sinceDay: Math.max(0, livedDay - AUTHORSHIP_DAYS),
|
|
1718
|
+
order: "desc",
|
|
1715
1719
|
limit: AUTHORSHIP_LIMIT,
|
|
1716
1720
|
});
|
|
1717
1721
|
return {
|
|
@@ -1719,10 +1723,9 @@ function rowsInWindow(
|
|
|
1719
1723
|
const date = rowDate(r);
|
|
1720
1724
|
return date !== null && date >= from;
|
|
1721
1725
|
}),
|
|
1722
|
-
//
|
|
1723
|
-
//
|
|
1724
|
-
//
|
|
1725
|
-
// diagnostic may never produce.
|
|
1726
|
+
// Read newest first, so a full read is missing the window's OLDEST rows
|
|
1727
|
+
// rather than today's. The counts are still a floor and the line says so;
|
|
1728
|
+
// a confident wrong number is the one thing a diagnostic may never produce.
|
|
1726
1729
|
truncated: all.length >= AUTHORSHIP_LIMIT,
|
|
1727
1730
|
};
|
|
1728
1731
|
}
|
|
@@ -2488,6 +2491,9 @@ export function upgradeV9Findings(store: Store): Finding[] {
|
|
|
2488
2491
|
];
|
|
2489
2492
|
}
|
|
2490
2493
|
|
|
2494
|
+
/** How many `band.promoted` rows the reflection finding reads, newest first. */
|
|
2495
|
+
export const PROMOTED_ROWS = 5000;
|
|
2496
|
+
|
|
2491
2497
|
/**
|
|
2492
2498
|
* REFLECTION, informational (2026-09-27): when the waking self last
|
|
2493
2499
|
* reflected, what it did, what became of the morning share; the week's
|
|
@@ -2507,10 +2513,17 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
|
|
|
2507
2513
|
// later — the half of "on reflection" the open door lets through (review
|
|
2508
2514
|
// of #256, S4). Counted apart from `alone`; one memory can be both.
|
|
2509
2515
|
let later = 0;
|
|
2516
|
+
let promotionsUnread = false;
|
|
2510
2517
|
try {
|
|
2511
2518
|
last = store.reflections({ limit: 5 }).find((r) => r.state === "reflected");
|
|
2512
2519
|
returns = store.returnCounts({ sinceAt: Date.parse(`${input.today}T00:00:00Z`) - 6 * 86_400_000 });
|
|
2513
|
-
|
|
2520
|
+
// Newest first with a named ceiling. The default read was the OLDEST 500
|
|
2521
|
+
// promotions, so the newest were the ones never counted; a read that comes
|
|
2522
|
+
// back full has not seen them all, and then the two counts are unknown
|
|
2523
|
+
// rather than a floor dressed as a total (as `newestRows` does).
|
|
2524
|
+
const promotions = store.eventLog({ name: "band.promoted", order: "desc", limit: PROMOTED_ROWS });
|
|
2525
|
+
promotionsUnread = promotions.length >= PROMOTED_ROWS;
|
|
2526
|
+
for (const row of promotions) {
|
|
2514
2527
|
try {
|
|
2515
2528
|
const p = JSON.parse(row.payload ?? "{}") as { reflectionOnly?: unknown; feelingRecordedLater?: unknown };
|
|
2516
2529
|
if (p.reflectionOnly === true) alone += 1;
|
|
@@ -2544,8 +2557,11 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
|
|
|
2544
2557
|
}${last.page_version === null ? "" : ", the self page rewritten"}, ${share[last.share_state] ?? last.share_state}`;
|
|
2545
2558
|
const byHow = `returns this week — awake ${String(returns.awake)}, reflection ${String(returns.reflection)}, dream ${String(returns.dream)}`;
|
|
2546
2559
|
const aloneLine =
|
|
2547
|
-
(
|
|
2548
|
-
|
|
2560
|
+
(promotionsUnread
|
|
2561
|
+
? `; how many became core on reflection alone is unknown: more than ${String(PROMOTED_ROWS)} promotions in the log, and only the newest ${String(PROMOTED_ROWS)} were read`
|
|
2562
|
+
: "") +
|
|
2563
|
+
(!promotionsUnread && alone > 0 ? `; ${String(alone)} ${alone === 1 ? "memory" : "memories"} became core on reflection alone` : "") +
|
|
2564
|
+
(!promotionsUnread && later > 0 ? `; ${String(later)} ${later === 1 ? "memory" : "memories"} became core on a feeling a reflection recorded later` : "") +
|
|
2549
2565
|
(relabeled > 0
|
|
2550
2566
|
? `; ${String(relabeled)} ${relabeled === 1 ? "mark" : "marks"} changed by a reflection, ${String(movedIn)} of them into me, us or the owner`
|
|
2551
2567
|
: "");
|
|
@@ -2564,8 +2580,8 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
|
|
|
2564
2580
|
returnsAwake: returns.awake,
|
|
2565
2581
|
returnsReflection: returns.reflection,
|
|
2566
2582
|
returnsDream: returns.dream,
|
|
2567
|
-
promotedOnReflectionAlone: alone,
|
|
2568
|
-
promotedOnFeelingRecordedLater: later,
|
|
2583
|
+
promotedOnReflectionAlone: promotionsUnread ? null : alone,
|
|
2584
|
+
promotedOnFeelingRecordedLater: promotionsUnread ? null : later,
|
|
2569
2585
|
relabeledByReflection: relabeled,
|
|
2570
2586
|
relabeledIntoCore: movedIn,
|
|
2571
2587
|
},
|
|
@@ -2574,30 +2590,42 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
|
|
|
2574
2590
|
}
|
|
2575
2591
|
|
|
2576
2592
|
/**
|
|
2577
|
-
* DREAMING, informational (2026-09-26):
|
|
2578
|
-
*
|
|
2579
|
-
* the
|
|
2593
|
+
* DREAMING, informational (2026-09-26): the owner's setting (2026-09-28:
|
|
2594
|
+
* auto, ask or off), when the counterpart last dreamed, and what today's line
|
|
2595
|
+
* did — started the nightly run, asked, or was declined. Never amber: not
|
|
2596
|
+
* dreaming is the owner's choice, and a quiet week is not a fault.
|
|
2580
2597
|
*/
|
|
2581
2598
|
export function dreamingFindings(input: DoctorInput, store: Store): Finding[] {
|
|
2582
2599
|
let last: ReturnType<Store["dreams"]>[number] | undefined;
|
|
2583
2600
|
let ask: ReturnType<Store["dreamAsk"]>;
|
|
2601
|
+
let setting: DreamingSetting;
|
|
2584
2602
|
try {
|
|
2585
2603
|
last = store.dreams({ limit: 5 }).find((d) => d.state !== "undone");
|
|
2586
2604
|
ask = store.dreamAsk(input.today);
|
|
2605
|
+
setting = dreamingSetting(store);
|
|
2587
2606
|
} catch {
|
|
2588
2607
|
return [];
|
|
2589
2608
|
}
|
|
2590
2609
|
const when = last === undefined ? null : (last.date ?? `lived day ${String(last.day)}`);
|
|
2591
2610
|
const today =
|
|
2592
|
-
|
|
2611
|
+
setting === "off"
|
|
2612
|
+
? "off — no dreams (counterparts dream --setting auto turns it back on)"
|
|
2613
|
+
: ask === undefined
|
|
2614
|
+
? "not started today"
|
|
2615
|
+
: ask.state === "declined"
|
|
2616
|
+
? "asked today; the owner said not today"
|
|
2617
|
+
: ask.state === "launched"
|
|
2618
|
+
? "started today, in the background"
|
|
2619
|
+
: "asked today";
|
|
2620
|
+
const unfinished = last !== undefined && last.state === "begun" ? `; dream ${last.id} is begun and not yet journaled` : "";
|
|
2593
2621
|
return [
|
|
2594
2622
|
finding(
|
|
2595
2623
|
"dreaming",
|
|
2596
2624
|
"green",
|
|
2597
2625
|
"Dreaming",
|
|
2598
|
-
`${when === null ? "has not dreamed yet" : `last dreamed ${when}${last?.title ? ` — "${last.title}"` : ""}`}; ${today}`,
|
|
2626
|
+
`${setting}; ${when === null ? "has not dreamed yet" : `last dreamed ${when}${last?.title ? ` — "${last.title}"` : ""}`}; ${today}${unfinished}`,
|
|
2599
2627
|
"",
|
|
2600
|
-
{ last: when, dream: last?.id ?? null, ask: ask?.state ?? null },
|
|
2628
|
+
{ setting, last: when, dream: last?.id ?? null, ask: ask?.state ?? null },
|
|
2601
2629
|
),
|
|
2602
2630
|
];
|
|
2603
2631
|
}
|
|
@@ -2679,10 +2707,18 @@ export function selfPageFindings(store: Store): Finding[] {
|
|
|
2679
2707
|
* Green also for a night that read the day and had nothing to say: that is the
|
|
2680
2708
|
* mechanism working, and it is stated in words rather than left as a silence.
|
|
2681
2709
|
*
|
|
2682
|
-
*
|
|
2683
|
-
*
|
|
2684
|
-
*
|
|
2685
|
-
*
|
|
2710
|
+
* Green when it is OFF, too — a deliberate choice is not a fault — with the
|
|
2711
|
+
* line saying what off means. (This comment and the adapter CONTRACT used to
|
|
2712
|
+
* say "amber while a page stands"; the code has said green since the S2
|
|
2713
|
+
* review, and the words now follow the code, 2026-09-28.)
|
|
2714
|
+
*
|
|
2715
|
+
* AMBER, with a fix, on the readings that mean something has stopped: a run
|
|
2716
|
+
* that failed or was refused, a pageWriter block that could not be read, and
|
|
2717
|
+
* — since the writer moved into the nightly run (2026-09-28) — a night owed
|
|
2718
|
+
* for days while nightly runs went on without it. A night owed because no run
|
|
2719
|
+
* started (fewer than three new memories, dreaming off or declined) is the
|
|
2720
|
+
* ordinary state of a quiet week and stays green. Never red: nothing here can
|
|
2721
|
+
* cost a session its memory.
|
|
2686
2722
|
*/
|
|
2687
2723
|
export function pageWriterFindings(store: Store, config: AdapterConfig): Finding[] {
|
|
2688
2724
|
const mode = pageWriterMode(config);
|
|
@@ -2746,7 +2782,9 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
|
|
|
2746
2782
|
"Page writer",
|
|
2747
2783
|
young
|
|
2748
2784
|
? `${mode} mode; never run — this store has no day before ${today} yet`
|
|
2749
|
-
:
|
|
2785
|
+
: mode === "session"
|
|
2786
|
+
? `${mode} mode; never run — it is the first part of the next nightly run, before the dream (${about})${dreamingSetting(store) === "off" ? "; dreaming is off, so the nightly run does not start" : ""}`
|
|
2787
|
+
: `${mode} mode; never run — the next boundary's worker starts it (${about})`,
|
|
2750
2788
|
"",
|
|
2751
2789
|
{ ...data, young },
|
|
2752
2790
|
),
|
|
@@ -2768,7 +2806,14 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
|
|
|
2768
2806
|
asksPerDay: SELF_TUNABLES.PAGE_WRITER_ASKS_PER_DAY,
|
|
2769
2807
|
});
|
|
2770
2808
|
const staleFor = last.on === "" ? 0 : daysBetween(last.on, today);
|
|
2771
|
-
|
|
2809
|
+
// OWED IS NOT OVERDUE on its own any more (2026-09-28). The writer runs
|
|
2810
|
+
// inside the nightly run, and a night with fewer than three new memories
|
|
2811
|
+
// runs nothing — the day carries over — so "owed for days" is the ordinary
|
|
2812
|
+
// state of a quiet week. It is amber only when nightly runs HAPPENED since
|
|
2813
|
+
// (a dream dated after the writer's last row, before today) and the writer
|
|
2814
|
+
// still left nothing: the run is going without it.
|
|
2815
|
+
const ranSince = mode === "session" && last.on !== "" ? dreamsBetween(store, last.on, today) : 0;
|
|
2816
|
+
const overdue = owed.due && staleFor > PAGE_WRITER_STALE_DAYS && (mode !== "session" || ranSince > 0);
|
|
2772
2817
|
const bad = status.outcome === "failed" || status.outcome === "refused";
|
|
2773
2818
|
const detail =
|
|
2774
2819
|
`${mode} mode; ${when} — ${status.outcome}` +
|
|
@@ -2785,7 +2830,9 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
|
|
|
2785
2830
|
"Page writer",
|
|
2786
2831
|
detail,
|
|
2787
2832
|
bad || overdue
|
|
2788
|
-
?
|
|
2833
|
+
? mode === "session"
|
|
2834
|
+
? "counterparts mechanisms --all --dir <store> --observer shows the run's own row. The page writer is the first part of the nightly run, before the dream: counterparts dream shows whether the runs are happening and how each ended. counterparts self-page --write amends the page by hand meanwhile."
|
|
2835
|
+
: "counterparts mechanisms --all --dir <store> --observer shows the run's own row. In host mode the boundary's worker starts a windowless session for the writer; a night that is owed but never delivered usually means that session could not start. counterparts self-page --write amends the page by hand meanwhile."
|
|
2789
2836
|
: "",
|
|
2790
2837
|
{
|
|
2791
2838
|
...data,
|
|
@@ -2810,6 +2857,15 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
|
|
|
2810
2857
|
* missed last night has not failed; one that has missed three has. */
|
|
2811
2858
|
export const PAGE_WRITER_STALE_DAYS = 2;
|
|
2812
2859
|
|
|
2860
|
+
/** Dreams begun on a calendar date after `after` and before `before` (not undone). Never throws. */
|
|
2861
|
+
function dreamsBetween(store: Store, after: string, before: string): number {
|
|
2862
|
+
try {
|
|
2863
|
+
return store.dreams({ limit: 50 }).filter((d) => d.state !== "undone" && d.date !== null && d.date > after && d.date < before).length;
|
|
2864
|
+
} catch {
|
|
2865
|
+
return 0;
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2813
2869
|
/** A page that was written and then cleared: when, why, and what is restorable.
|
|
2814
2870
|
* Null when no page row exists at all. */
|
|
2815
2871
|
function clearedPage(
|