counterparts 0.3.11 → 0.3.13
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 +326 -0
- package/docs/QUICKSTART.md +5 -0
- package/docs/README.md +2 -2
- package/docs/module-map.md +3 -3
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +36 -10
- package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
- package/src/adapters/claude-code/NOTES.md +182 -0
- package/src/adapters/claude-code/bin/hook.ts +46 -12
- package/src/adapters/claude-code/bin/runner.ts +7 -1
- package/src/adapters/claude-code/doctor.ts +632 -18
- package/src/adapters/claude-code/hooks.ts +61 -16
- package/src/adapters/claude-code/index.ts +11 -0
- package/src/adapters/claude-code/night-run.ts +150 -14
- package/src/adapters/claude-code/transcript.ts +268 -1
- package/src/adapters/cli/CONTRACT.md +5 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
- package/src/adapters/cli/NOTES.md +111 -0
- package/src/adapters/cli/commands.ts +134 -92
- package/src/adapters/cli/dream-core.ts +57 -42
- package/src/adapters/cli/export.ts +320 -21
- package/src/adapters/cli/help.ts +2 -1
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +39 -7
- package/src/adapters/cli/mechanisms.ts +7 -1
- package/src/adapters/cli/uninstall.ts +13 -5
- package/src/adapters/cli/wire.ts +189 -63
- package/src/adapters/config.ts +2 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
- package/src/adapters/dashboard/NOTES.md +79 -0
- package/src/adapters/dashboard/registries.ts +34 -2
- package/src/adapters/dashboard/web/README.md +19 -14
- package/src/adapters/dashboard/web/actions.ts +23 -1
- package/src/adapters/dashboard/web/flow.ts +14 -0
- package/src/adapters/dashboard/web/lanes.ts +10 -0
- package/src/adapters/dashboard/web/narrate.ts +88 -2
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
- package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
- package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
- package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
- package/src/adapters/dashboard/web/server.ts +0 -5
- package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
- package/src/adapters/dashboard/web/views/health.ts +21 -3
- package/src/adapters/dashboard/web/views/search.ts +4 -45
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +430 -28
- package/src/adapters/host-wiring.ts +300 -0
- package/src/adapters/hosts.ts +11 -0
- package/src/adapters/lifecycle.ts +42 -2
- package/src/adapters/log/index.ts +9 -0
- package/src/adapters/mcp/CONTRACT.md +151 -11
- package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
- package/src/adapters/mcp/NOTES.md +313 -1
- package/src/adapters/mcp/bin/serve.ts +74 -1
- package/src/adapters/mcp/deliberate.ts +169 -651
- package/src/adapters/mcp/facts.ts +1094 -0
- package/src/adapters/mcp/index.ts +25 -7
- package/src/adapters/mcp/meaning.ts +1610 -0
- package/src/adapters/mcp/server.ts +835 -150
- package/src/adapters/mcp/stdio.ts +3 -1
- package/src/adapters/mcp/stood-down.ts +51 -0
- package/src/adapters/mcp/tools.ts +167 -41
- package/src/adapters/plugin-run.sh +133 -0
- package/src/adapters/plugin.ts +329 -0
- package/src/adapters/sessions.ts +18 -4
- package/src/core/associate/CONTRACT.md +2 -1
- package/src/core/associate/INTERFACE-GAPS.md +6 -1
- package/src/core/associate/NOTES.md +45 -0
- package/src/core/briefing.ts +12 -3
- package/src/core/contradictions.ts +184 -0
- package/src/core/counterpart.ts +797 -51
- package/src/core/dream/CONTRACT.md +36 -4
- package/src/core/dream/INTERFACE-GAPS.md +29 -6
- package/src/core/dream/NOTES.md +107 -0
- package/src/core/dream/feeling-weeks.ts +198 -0
- package/src/core/dream/index.ts +109 -18
- package/src/core/dream/reflect.ts +346 -87
- package/src/core/dream/tunables.ts +24 -4
- package/src/core/encode/INTERFACE-GAPS.md +3 -1
- package/src/core/encode/NOTES.md +7 -0
- package/src/core/encode/words.ts +45 -0
- package/src/core/fit/INTERFACE-GAPS.md +8 -2
- package/src/core/fit/NOTES.md +39 -1
- package/src/core/fit/index.ts +40 -0
- package/src/core/handoff/CONTRACT.md +37 -2
- package/src/core/handoff/INTERFACE-GAPS.md +10 -0
- package/src/core/handoff/NOTES.md +72 -0
- package/src/core/handoff/index.ts +214 -12
- package/src/core/handoff/last-here.ts +6 -4
- package/src/core/mint.ts +12 -2
- package/src/core/physics/CONTRACT.md +14 -2
- package/src/core/physics/NOTES.md +33 -1
- package/src/core/physics/index.ts +28 -5
- package/src/core/prospective/CONTRACT.md +45 -6
- package/src/core/prospective/INTERFACE-GAPS.md +4 -0
- package/src/core/prospective/NOTES.md +138 -0
- package/src/core/prospective/derive.ts +33 -5
- package/src/core/prospective/index.ts +90 -5
- package/src/core/prospective/windows.ts +72 -1
- package/src/core/recall/CONTRACT.md +31 -12
- package/src/core/recall/INTERFACE-GAPS.md +28 -4
- package/src/core/recall/NOTES.md +70 -1
- package/src/core/recall/feeling-ask.ts +10 -1
- package/src/core/recall/index.ts +3 -1
- package/src/core/recall/probe.ts +58 -0
- package/src/core/recall/session.ts +46 -2
- package/src/core/recall/time-ask.ts +487 -0
- package/src/core/remember/CONTRACT.md +4 -1
- package/src/core/remember/INTERFACE-GAPS.md +9 -1
- package/src/core/remember/NOTES.md +8 -0
- package/src/core/remember/proposals.ts +47 -5
- package/src/core/revision.ts +18 -1
- package/src/core/schemas/CONTRACT.md +21 -1
- package/src/core/schemas/INTERFACE-GAPS.md +20 -2
- package/src/core/schemas/NOTES.md +144 -0
- package/src/core/schemas/aliases.ts +55 -5
- package/src/core/schemas/index.ts +93 -1
- package/src/core/schemas/types.ts +2 -0
- package/src/core/self/CONTRACT.md +32 -5
- package/src/core/self/INTERFACE-GAPS.md +7 -2
- package/src/core/self/NOTES.md +102 -1
- package/src/core/self/behind.ts +43 -3
- package/src/core/self/briefing.ts +12 -2
- package/src/core/self/chapter-address.ts +254 -0
- package/src/core/self/episodes.ts +27 -0
- package/src/core/self/index.ts +83 -8
- package/src/core/self/page.ts +88 -0
- package/src/core/self/tunables.ts +5 -0
- package/src/core/self/work.ts +35 -2
- package/src/core/self/writer.ts +30 -0
- package/src/core/sleep/INTERFACE-GAPS.md +22 -3
- package/src/core/sleep/NOTES.md +20 -1
- package/src/core/sleep/consolidate.ts +59 -7
- package/src/core/sleep/index.ts +3 -0
- package/src/core/sleep/prune.ts +6 -2
- package/src/core/sleep/types.ts +7 -0
- package/src/core/store/CONTRACT.md +16 -0
- package/src/core/store/NOTES.md +66 -0
- package/src/core/store/feelings.ts +14 -1
- package/src/core/store/index.ts +483 -16
- package/src/core/store/operational.ts +95 -2
- package/src/core/store/owner-op-seam.ts +23 -0
- package/src/core/time.ts +152 -0
- package/tools/install-loop/run.sh +48 -12
- package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
|
@@ -124,13 +124,16 @@ dreamer is the model (a background agent the session launches), outside this pro
|
|
|
124
124
|
`timed-out` | `could-not-start`, reason, exit code, its watchdog, the PARTS that ran —
|
|
125
125
|
writer, dream, reflection — and the dream and reflection it produced), each state
|
|
126
126
|
on the `dream.night` event log latched by run and state. Ids, codes and times only.
|
|
127
|
-
Doctor's Nightly run line reads it; the dashboard can later.
|
|
127
|
+
Doctor's Nightly run line reads it; the dashboard can later. Since 2026-10-09 the host
|
|
128
|
+
adds what the child's transcript said: `transcript` (`read` | `absent` | `unreadable`)
|
|
129
|
+
and, when read, `spills` — results the host cut to a preview.
|
|
128
130
|
- **The hand-back of a headless run** — the dream's own line (`handBackOf`) and the
|
|
129
131
|
morning share — has no agent to return to a session, so once the run has ended the
|
|
130
132
|
next prompt anywhere, the launching session included, carries both, once ever (a
|
|
131
133
|
latched `dream.night.handed` event, then `handedAt` on the row so later prompts only
|
|
132
134
|
read; the share through `Reflections.carryLine`). A partial run's line says it was
|
|
133
|
-
partial; a reflection-alone run hands back its share only.
|
|
135
|
+
partial; a reflection-alone run hands back its share only. A run with `spills` adds one
|
|
136
|
+
plain line (`nightSpillLine`, 2026-10-09) — handed back even when it journaled nothing.
|
|
134
137
|
- **A run left behind does not use up the day.** A dream begun, never journaled and
|
|
135
138
|
quiet for `ABANDONED_AFTER_MS` (30 minutes: its session closed and the background
|
|
136
139
|
agent went with it), today's or yesterday's, makes the line due again once the line
|
|
@@ -209,7 +212,8 @@ dreamer is the model (a background agent the session launches), outside this pro
|
|
|
209
212
|
`merge` (two or more near-copies, not core, into one memory in better words, under
|
|
210
213
|
the strongest original's kind when the kinds differ; the
|
|
211
214
|
merged memory stands where the strongest original stood, carries their returns,
|
|
212
|
-
feelings and trait nudges — each nudge keeping its source, model and moment
|
|
215
|
+
feelings and trait nudges — each nudge keeping its source, model and moment, each
|
|
216
|
+
feeling its source, its recorded-later date and (since 2026-10-02) its moment — and
|
|
213
217
|
inherits their links), `link` (both ways, proposed at `LINK_WEIGHT` through
|
|
214
218
|
`associate`, only where there is room, since 2026-09-28), `replayed` (a
|
|
215
219
|
return at `DREAM_RETURN_WEIGHT`, never a use), `gist` (source `dreamed`, citing and
|
|
@@ -276,7 +280,19 @@ dream having run.
|
|
|
276
280
|
the self page, the core, the core candidates, the most strongly felt memories that
|
|
277
281
|
could be about me (marked or not), and memories that became core on reflection alone
|
|
278
282
|
since a share last said so — as memories and feelings, **never the lane arithmetic**.
|
|
279
|
-
|
|
283
|
+
Since 2026-10-02 (lane B) also **feelings over weeks** (`feeling-weeks.ts`; a few
|
|
284
|
+
hundred characters): counts by core per seven-day window for four weeks, mine and the
|
|
285
|
+
owner's apart, what changed (the last two weeks against the two before), how many were
|
|
286
|
+
recorded looking back (per core), and the ids it rests on — handed like the rest, so the entry and
|
|
287
|
+
the page can cite them. Counted from stored feelings (written at the time or recorded
|
|
288
|
+
later), never text; not a dream's feeling-now, nor one on what a dream or a reflection
|
|
289
|
+
wrote; null on a month with none. And **unmarked** — at most `UNMARKED` (5) memories
|
|
290
|
+
nobody has marked that the work lane counts as a project's work only for want of a
|
|
291
|
+
mark (`self/work.ts#isWorkMemory`: a fact, entity or place written in a directory; not
|
|
292
|
+
a skill, not a journal copy), those with a feeling, an entity or the owner's name
|
|
293
|
+
first, then the most used, then the oldest, rotated so the last three nights' offers
|
|
294
|
+
wait behind the rest — offered to be marked by meaning. A writer's mark is never
|
|
295
|
+
offered. A reflection's own later feelings are counted but never make a change. Three questions, rotated so consecutive nights share none (the dream question only
|
|
280
296
|
after a dream). **In parts, not cut** (2026-09-28): a bundle longer than
|
|
281
297
|
`RESULT_CHARS` (the tool result's ceiling is about 25k tokens) comes as part 1 of N —
|
|
282
298
|
everything but the long lists, which go on in order as far as the room allows — and
|
|
@@ -320,6 +336,18 @@ dream having run.
|
|
|
320
336
|
- **Feelings** are the self's, recorded later (`source: reflection`, `recorded_later`
|
|
321
337
|
= today), and may be stronger than anything felt at the time (at most 5) — on a
|
|
322
338
|
lived memory only: not on a dream's gist or a reflection's own entry (review of #256).
|
|
339
|
+
The same path (`Reflections#laterFeeling`) records an awake session's (below).
|
|
340
|
+
- **Awake, too** (2026-10-02, lane B): `feelAgain` — `note`'s `feelingsNow` — records
|
|
341
|
+
a later feeling from an ordinary session, through the reflection's path and its
|
|
342
|
+
guarantees, plus three: only a memory the session was shown (the door hands the set
|
|
343
|
+
in: what recall surfaced or returned, a write's neighbours; one not shown is refused
|
|
344
|
+
with the way in), at most one awake feeling-now a calendar day per memory
|
|
345
|
+
(`once-a-day`), and labeled — `source: awake`, `recorded_later` = today, carried_by
|
|
346
|
+
"looking back, awake, <date>: …". Mine by default, the owner's when they said so. At
|
|
347
|
+
most `AWAKE_FEELINGS` (5) a call. The core's fast lane reads it only through the
|
|
348
|
+
reflected-feeling door, as a reflection's (`store/feelings.ts#LATER_FEELING_SOURCES`);
|
|
349
|
+
a memory it carries to the core is not named by a share as the reflection's
|
|
350
|
+
(`PromotionRecord.feelingRecordedLaterBy`, review of #317).
|
|
323
351
|
- **About marks** (at most 8): `me`, `us`, `owner`, `work`, `world`, each with a why
|
|
324
352
|
(one not given is recorded as "no why given"); a core mark on a dream's gist or a
|
|
325
353
|
reflection's own entry is refused (`work`/`world` stay open on those); one on a
|
|
@@ -342,6 +370,10 @@ dream having run.
|
|
|
342
370
|
earns no return by being cited; **[M]** its hand-back carries the mark, so
|
|
343
371
|
the share is told in the session's own words, not captured from the tool's; **[M]**
|
|
344
372
|
the owner's removal redacts a reflection that was shown, cited or quotes the memory.
|
|
373
|
+
- **A gist takes the writer's three fields** (v12, 2026-10-03): `occurredOn`, `saidBy`,
|
|
374
|
+
`status`, read loose-first — **[M]** one that cannot be read is left off with a note and
|
|
375
|
+
the gist is written; nothing is defaulted. A merge takes none; the store carries each
|
|
376
|
+
original's to the merged memory (`store/` guarantee 26).
|
|
345
377
|
|
|
346
378
|
## 6. Scars honored
|
|
347
379
|
|
|
@@ -6,17 +6,28 @@ What this module still owes, or asks of others (2026-09-26).
|
|
|
6
6
|
store through the MCP server (launch → begin → propose → journal, then
|
|
7
7
|
`counterparts dream --show/--undo`); a real Claude Code session launching the Agent
|
|
8
8
|
tool with the prompt has not yet been watched end to end on the owner's machine.
|
|
9
|
+
*(CLOSED 2026-09-29, noted 2026-10-09: on the owner's machine that day a session's
|
|
10
|
+
launch went through once he said yes, after the host's classifier had refused the
|
|
11
|
+
unasked one (NOTES 2026-09-29). Since then `auto` runs headless (#282,
|
|
12
|
+
`night-run.ts`), and the dream and the reflection have run on his machine night after
|
|
13
|
+
night: IMPROVEMENTS U14 records the nights of 10-02 to 10-07.)*
|
|
9
14
|
2. **The ask is claimed when composed**, not at delivery. If the host drops the line
|
|
10
15
|
(envelope limits), that day's ask is lost. The plain reminders' pattern
|
|
11
16
|
(`bin/hook.ts#deliverTurn` → claim only what the envelope carries) is the fix.
|
|
17
|
+
*(CLOSED 2026-09-29 by #282 (`401fc31`), noted 2026-10-09: `Dreams.offer` composes
|
|
18
|
+
without claiming, and the host claims the day (`claimOffer`) only once the envelope
|
|
19
|
+
carries the person's line; otherwise the next prompt offers it again.)*
|
|
12
20
|
3. **A subagent's own turns (the sidechain).** On current hosts a subagent's transcript
|
|
13
21
|
is a separate file the boundary does not read; if a host ever writes a dreamer's
|
|
14
22
|
turns into the parent's file, only turns carrying the mark are refused. The
|
|
15
23
|
dreamer's final message is the marked hand-back by instruction and by the tool
|
|
16
24
|
handing it the words.
|
|
17
|
-
4.
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
4. **There is no door to remove one dream's journal** short of undoing it (which keeps
|
|
26
|
+
it, marked undone). The owner's removal of a MEMORY blanks its address in
|
|
27
|
+
`dream_changes`. *(The other half of this item — `export --markdown` did not carry the
|
|
28
|
+
`dreams` table — is CLOSED 2026-10-09: one file per dream under `dreams/`, its journal
|
|
29
|
+
and its changes; one resting on a confidential memory is left out unless
|
|
30
|
+
`--include-confidential`, and counted. `cli/NOTES.md`.)*
|
|
20
31
|
5. **Merged memories keep no embedding** until the next backfill embeds them (as any new
|
|
21
32
|
memory).
|
|
22
33
|
6. **Dream links are ordinary edges.** If the association work wants them marked (a
|
|
@@ -30,8 +41,13 @@ What this module still owes, or asks of others (2026-09-26).
|
|
|
30
41
|
- **A reflection on its own has no trigger**: `reflect launch` exists, but nothing asks
|
|
31
42
|
for one on a dreamless day. The old SessionStart page writer still covers those
|
|
32
43
|
nights.
|
|
33
|
-
- **Not yet watched live** with a real background agent.
|
|
34
|
-
|
|
44
|
+
- **Not yet watched live** with a real background agent. *(CLOSED with §1: the nightly
|
|
45
|
+
run's reflection has run on the owner's machine night after night, and on 10-07 it
|
|
46
|
+
rewrote the self page and its morning share reported the cut bundles (IMPROVEMENTS
|
|
47
|
+
U14).)*
|
|
48
|
+
- ~~**`export --markdown` does not carry the `reflections` table**~~ — CLOSED
|
|
49
|
+
2026-10-09: one file per reflection under `reflections/`, with its morning share and
|
|
50
|
+
what became of it (as §4 for dreams).
|
|
35
51
|
- **The crash-fallback sweep sets no about mark**: a self memory it mints is unmarked,
|
|
36
52
|
so not a core candidate until something awake marks it. A choice, not an oversight —
|
|
37
53
|
the sweep is a reteller.
|
|
@@ -41,12 +57,19 @@ What this module still owes, or asks of others (2026-09-26).
|
|
|
41
57
|
session switches it over (its `DashboardSource` does not carry `dreams` yet). The
|
|
42
58
|
dashboard is an observer: it passes `owner: true` to preview the owner's own gate
|
|
43
59
|
(confidential memories counted), or leaves it off for a guest's — its call.
|
|
60
|
+
*(CLOSED 2026-09-27, then moot; noted 2026-10-09: `DashboardSource` gained `dreams`
|
|
61
|
+
and the Tonight line read the gate's preview (#263, `8032668`), and the next day Home
|
|
62
|
+
round 4 took the Tonight box out (#273, `2cc96b0`). `DashboardSource.dreams` is still
|
|
63
|
+
wired, but nothing in the dashboard calls `previewAsk` today.)*
|
|
44
64
|
|
|
45
65
|
9. **Trait nudges have no reader in the core (2026-09-27), on purpose.** The dashboard's
|
|
46
66
|
Self tab is to draw each axis as a firmness-weighted balance from `Store#traitsAll()`
|
|
47
67
|
(or `traitsOn(ids)` for the memories it already holds); until it does, nudges are
|
|
48
68
|
visible only in `export --markdown` and the `fired` row. A dream backfill of older
|
|
49
|
-
memories is not built.
|
|
69
|
+
memories is not built. *(The dashboard half CLOSED 2026-09-27 by #266 (`80720e0`),
|
|
70
|
+
noted 2026-10-09: the Self tab's "How I act" draws the seven axes as firmness-weighted
|
|
71
|
+
balances from `traitsAll` (`dashboard/web/views/traits.ts`). The core still has no
|
|
72
|
+
reader, on purpose, and the backfill is still not built.)*
|
|
50
73
|
|
|
51
74
|
10. **Contradictions (2026-09-29).** The dream flags and may settle; the reflection may
|
|
52
75
|
settle. Not built: the PAGE WRITER has no settle door of its own — a night-run
|
package/src/core/dream/NOTES.md
CHANGED
|
@@ -439,3 +439,110 @@ writer, the dream and the reflection. What the build learned:
|
|
|
439
439
|
- An undone dream's settle leaves its pair `withdrawn` when nobody had flagged it, and
|
|
440
440
|
`unsettled` when it was a flag; the trail's actor is `dream-undo` with the dream id (M4).
|
|
441
441
|
- A reopened flag starts fresh on "my mind" (its `mind.seen.<pair>` count is reset, M5).
|
|
442
|
+
|
|
443
|
+
## 2026-10-02 — lane B: feelings over weeks, re-feeling awake, unmarked offered (held lightly)
|
|
444
|
+
|
|
445
|
+
- **Feelings over weeks** (`feeling-weeks.ts`). Rolling seven-day windows ending today,
|
|
446
|
+
four of them, in the person's zone, each feeling dated by when it was recorded. "What
|
|
447
|
+
changed" compares the last two windows with the two before: a core moved when the
|
|
448
|
+
difference is at least `MIN_CHANGE` (2) and one side is at least twice the other — so
|
|
449
|
+
1 → 3 is a rise, 3 → 4 is not. The ids it rests on are the strongest feelings behind
|
|
450
|
+
each change (the recent ones for a rise, the earlier ones for a fall), or behind my
|
|
451
|
+
commonest core when nothing changed; at most 6, only what the reflection may see.
|
|
452
|
+
It does not say "around releases": that is the reflection's to read off the memories
|
|
453
|
+
it rests on. A sample from the test: `{"weeks":["2026-09-05",…,"2026-09-26"],
|
|
454
|
+
"mine":{"uneasy":[0,1,0,3],"warm":[0,0,0,1]},"owner":{"happy":[2,0,0,0]},
|
|
455
|
+
"lookingBack":0,"changed":["my uneasy up: 1 in the two weeks before, 3 in the last
|
|
456
|
+
two","the owner's happy down: 2 in the two weeks before, 0 in the last two"],
|
|
457
|
+
"restsOn":[five ids]}` — 403 characters.
|
|
458
|
+
- **The merge kept feelings' source and date-recorded-later but not their moment**:
|
|
459
|
+
`addFeelings` stamped `created_at = now`, so every feeling a merge carried read as
|
|
460
|
+
felt on the merge night — a spike in the weeks, and a morning mood from a dream's
|
|
461
|
+
housekeeping. `provenance` carries `createdAt` now, as a trait nudge's does.
|
|
462
|
+
- **Re-feeling awake reuses the reflection's path** rather than the session's
|
|
463
|
+
`feelings`: the guarantees that make a later feeling safe (shown only, lived only, the
|
|
464
|
+
credential scan on the whole emotion, no doubles, the strength default capped below
|
|
465
|
+
the fast lane, `recorded_later`) were all in `finish`'s loop; it is one method now
|
|
466
|
+
(`laterFeeling`), called by both. Source `awake`, not `reflection`: the dashboard and
|
|
467
|
+
doctor can tell a session's look back from the night's.
|
|
468
|
+
- **Unmarked, offered**: the brief's "fact/entity ones that mention people or feelings"
|
|
469
|
+
is read from what the store holds — a recorded feeling, kind `entity`, the owner's name
|
|
470
|
+
in the words — not from guessing at names in text. They count toward the night's 8
|
|
471
|
+
about marks, and the instructions say so.
|
|
472
|
+
|
|
473
|
+
### After the review of #316
|
|
474
|
+
|
|
475
|
+
- **A reflection's own later feelings stay out of `changed`** (they are still counted):
|
|
476
|
+
three uneasy it records tonight would otherwise read tomorrow as "my uneasy up" — the
|
|
477
|
+
reflection reading itself back. An awake look back is the session's and does count.
|
|
478
|
+
`lookingBack` is per core now, mine and the owner's (one number said nothing).
|
|
479
|
+
The sources come from `store/feelings.ts` (`FEELING_SOURCES`, `LATER_FEELING_SOURCES`).
|
|
480
|
+
- **Unmarked offers rotate.** The ids a reflection was offered are kept in its detail
|
|
481
|
+
(`detail.unmarked`, carried across `finish`); what the last `UNMARKED_REST_NIGHTS` (3)
|
|
482
|
+
reflections were offered waits behind the rest and comes back when the rest run out —
|
|
483
|
+
so a pool left unmarked (a personal one on a closed-door night) is not the same five
|
|
484
|
+
every night.
|
|
485
|
+
- **The awake way to the fast lane stays loose and is made visible**:
|
|
486
|
+
`awakeFeelingCounts` reads the `awake` rows on live memories (how many, how many at
|
|
487
|
+
`CORE_FAST_FEELING`, how many the owner's), and doctor's Reflection line says them in
|
|
488
|
+
one clause.
|
|
489
|
+
|
|
490
|
+
## 2026-10-02 — bundles are read as a guest (review of #318)
|
|
491
|
+
|
|
492
|
+
Until #318 every server that built a dream's or a reflection's bundle was a guest. Since it,
|
|
493
|
+
Claude Code's server is the owner's, and in `ask` mode (the default) and `reflect launch` the
|
|
494
|
+
background agent calls that server. `BUNDLE_OWNER` (`tunables.ts`, false) keeps the bundles as
|
|
495
|
+
they were — kept as before, a coordinator default the owner may revisit: `Dreams#showable`,
|
|
496
|
+
its queue reads, the on-my-mind ranking, the aged-out read and the chapters, and the same in
|
|
497
|
+
`Reflections` (`showable(row, owner = BUNDLE_OWNER)`, `recentChapters`, the chapter fit). A
|
|
498
|
+
dream's journal and a nomination's `why` carry no confidentiality mark and are read later by
|
|
499
|
+
other bundles and the dashboard. The dream's gate (`gate`, `previewAsk`, the offer's count)
|
|
500
|
+
keeps `ctx.owner`, and so does a share's delivery (`pendingShare`, `carryLine`). Feeling again
|
|
501
|
+
awake (`feelAgain`) takes the call's own stance (#317 × #318).
|
|
502
|
+
No host reads a bundle as the owner; `CounterpartOptions.bundlesAsOwner` (`ctx.bundleOwner`)
|
|
503
|
+
exists for the store-level tests of what an owner-read bundle must keep — a merge of a
|
|
504
|
+
confidential memory is confidential, a page rests on nothing confidential — which opt in.
|
|
505
|
+
|
|
506
|
+
**Two things the guest bundle does not cover, for now (2026-10-02, left open for the owner).**
|
|
507
|
+
- *A recall during an `ask` dream.* The dream's background agent calls the session's own
|
|
508
|
+
server, which is the owner's since #318. The bundle and its parts stay guest, but a `recall`
|
|
509
|
+
BY QUESTION the agent makes mid-dream answers as that server does, so it can return a
|
|
510
|
+
confidential memory's text — and what the agent writes then lands in the dream's journal,
|
|
511
|
+
which carries no confidentiality mark. By id it would need a confidential id, which the
|
|
512
|
+
bundle never hands it (only such a recall could). Narrow; not closed here — whether the
|
|
513
|
+
dream's recall should read as a guest, or the journal take a mark, is the owner's call.
|
|
514
|
+
- *The ask can promise more than the bundle holds.* The gate (`gate`, `previewAsk`, the
|
|
515
|
+
offer's count) keeps `ctx.owner`, so it counts confidential new memories that the guest
|
|
516
|
+
bundle then leaves out: on a store whose only new memories are confidential, "yes, dream"
|
|
517
|
+
can come back with nothing new. A known quirk, kept as is.
|
|
518
|
+
|
|
519
|
+
## 2026-10-03 — a gist takes the writer's three fields (schema v12)
|
|
520
|
+
|
|
521
|
+
- `gist` takes `occurredOn`, `saidBy` and `status` (prompt line and the `dream` tool's
|
|
522
|
+
schema), read loose-first by `gistFacts`: what reads goes on the row, what does not is
|
|
523
|
+
left off with a note and the gist is written. Nothing is defaulted — a gist is plainly an
|
|
524
|
+
inference, but doctor's `Write fields` line measures what the writer fills, so an
|
|
525
|
+
engine-set `inferred` would read as the writer's. A merge takes no fields; the store
|
|
526
|
+
carries each original's to the merged memory where it has none (`carryWriteFacts`, the
|
|
527
|
+
first original that has one, as the about-mark). Reflection entries do not take them yet.
|
|
528
|
+
|
|
529
|
+
## 2026-10-09 — a reflection in parts is told to read every part first
|
|
530
|
+
|
|
531
|
+
On the 0.3.12 release-check copy of the owner's store, a reflection handed its bundle in 2
|
|
532
|
+
parts finished without fetching part 2 (doctor's Tool results line measures "every part
|
|
533
|
+
read"). The launch prompt and part 1's `parts.next` both said to fetch the rest "before you
|
|
534
|
+
answer", but `how` — the instructions beside the bundle, which read as the procedure — went
|
|
535
|
+
from "Reflect on the questions" straight to "call finish", with no word about parts. The
|
|
536
|
+
dream's `how` gives no procedure of its own, so its launch prompt's "before you change
|
|
537
|
+
anything" stands alone there.
|
|
538
|
+
|
|
539
|
+
- `instructions` now opens, when the bundle comes in parts, with "First, read every part:
|
|
540
|
+
this bundle comes in N parts and this is part 1", the exact `part` call for part 2 (and
|
|
541
|
+
"each part up to N"), and "reflect and write only once you have read them all".
|
|
542
|
+
- `pack` measures the instructions with that line in place (a placeholder note of 99
|
|
543
|
+
parts), so the first part's room is not overrun by the line that says it is a part.
|
|
544
|
+
- "before you answer" became "before you answer or write anything" in the two reflection
|
|
545
|
+
launch prompts, the night's launch prompt and `parts.next`: "answer" alone can read as
|
|
546
|
+
the final message, and the finish call is writing.
|
|
547
|
+
|
|
548
|
+
Untested against a model: whether this is enough. Doctor's line is the measure.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dream/feeling-weeks.ts` — FEELINGS OVER WEEKS, for the nightly reflection
|
|
3
|
+
* (2026-10-02, lane B, owner pick 1; working defaults, held lightly).
|
|
4
|
+
*
|
|
5
|
+
* The reflection was shown each memory's feelings, one memory at a time, and
|
|
6
|
+
* nothing of how they ran: whether I have been more uneasy lately, whether the
|
|
7
|
+
* owner's warmth went quiet. This is that pattern, small: counts by core per
|
|
8
|
+
* week for the last few weeks, mine and the owner's apart; what changed (the
|
|
9
|
+
* last two weeks against the two before); and a few memory ids it rests on, so
|
|
10
|
+
* the reflection can read them, cite them, and — if it means something — say
|
|
11
|
+
* it on the self page in its own words, through the page's own door.
|
|
12
|
+
*
|
|
13
|
+
* COMPUTED FROM STORED FEELINGS, never from text: every feeling on a live,
|
|
14
|
+
* lived memory, as written at the time or recorded later (a reflection's, an
|
|
15
|
+
* awake feeling-now) — each dated by when it was recorded, in the person's
|
|
16
|
+
* zone. Not a dream's feeling-now (a dream is not lived), and not a feeling on
|
|
17
|
+
* what a dream or a reflection wrote. Counts carry no words, so a confidential
|
|
18
|
+
* memory's feelings count; only what `citable` allows is named in `restsOn`.
|
|
19
|
+
*
|
|
20
|
+
* A few hundred characters in the bundle. No dashboard page: this is the
|
|
21
|
+
* reflection's to read, not another place to show the same thing.
|
|
22
|
+
*/
|
|
23
|
+
import { addDays, daysBetween, isDay, localDate } from "../time.js";
|
|
24
|
+
import { TUNABLES as PHYSICS_TUNABLES } from "../physics/index.js";
|
|
25
|
+
import { FEELING_SOURCES, LATER_FEELING_SOURCES } from "../store/index.js";
|
|
26
|
+
import type { FeelingSource, MemoryRow, Store } from "../store/index.js";
|
|
27
|
+
|
|
28
|
+
export const FEELING_WEEKS_TUNABLES = {
|
|
29
|
+
/** Seven-day windows, the last ending today. */
|
|
30
|
+
WEEKS: 4,
|
|
31
|
+
/** The most cores named per person (the commonest in the span). */
|
|
32
|
+
CORES_SHOWN: 4,
|
|
33
|
+
/** A core "went up" when the last two weeks have at least this many more than the two before, and at least twice as many. CAL. */
|
|
34
|
+
MIN_CHANGE: 2,
|
|
35
|
+
/** What-changed lines at most. */
|
|
36
|
+
CHANGED: 3,
|
|
37
|
+
/** Memory ids the pattern rests on, at most, and per line of change. */
|
|
38
|
+
RESTS_ON: 6,
|
|
39
|
+
PER_CHANGE: 3,
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
export interface FeelingWeeks {
|
|
43
|
+
/** The first day of each seven-day window, oldest first; the last window ends today. */
|
|
44
|
+
readonly weeks: readonly string[];
|
|
45
|
+
/** My feelings by core, a count per window (oldest first). A core with none in the span is left out. */
|
|
46
|
+
readonly mine: Readonly<Record<string, readonly number[]>>;
|
|
47
|
+
/** The owner's, the same way. */
|
|
48
|
+
readonly owner: Readonly<Record<string, readonly number[]>>;
|
|
49
|
+
/**
|
|
50
|
+
* Of the counts above, how many were recorded LATER, looking back (by a
|
|
51
|
+
* reflection or awake), by core — mine and the owner's; a core with none is
|
|
52
|
+
* left out. Review of #316: one number for everything said nothing.
|
|
53
|
+
*/
|
|
54
|
+
readonly lookingBack: { readonly mine: Readonly<Record<string, number>>; readonly owner: Readonly<Record<string, number>> };
|
|
55
|
+
/**
|
|
56
|
+
* What changed, the last two weeks against the two before, in words. Empty
|
|
57
|
+
* on a steady month. A reflection's OWN later feelings are left out of it
|
|
58
|
+
* (review of #316): three uneasy recorded tonight must not read tomorrow as
|
|
59
|
+
* "my uneasy up" — the reflection would be reading itself back.
|
|
60
|
+
*/
|
|
61
|
+
readonly changed: readonly string[];
|
|
62
|
+
/** Memory ids the pattern rests on — the strongest feelings behind what changed (or behind the commonest core). Read them before you cite them. */
|
|
63
|
+
readonly restsOn: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Every source but a dream's feeling-now (a dream is not lived); null is a bare row, felt at the time. */
|
|
67
|
+
const COUNTED_SOURCES = new Set<string | null>([null, ...FEELING_SOURCES.filter((x) => x !== "dream")]);
|
|
68
|
+
const LATER = new Set<string | null>(LATER_FEELING_SOURCES);
|
|
69
|
+
/** The source left out of `changed`: the reader's own. */
|
|
70
|
+
const OWN: FeelingSource = "reflection";
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The pattern as of `today` (a calendar day), or null when no feeling was
|
|
74
|
+
* recorded in the span — a quiet month says nothing, and the bundle carries no
|
|
75
|
+
* empty field. `citable` says which memories may be named in `restsOn` (the
|
|
76
|
+
* reflection's showable rule).
|
|
77
|
+
*/
|
|
78
|
+
export function feelingWeeks(
|
|
79
|
+
store: Pick<Store, "feelingsLive" | "row" | "zone">,
|
|
80
|
+
today: string,
|
|
81
|
+
citable: (row: MemoryRow) => boolean,
|
|
82
|
+
): FeelingWeeks | null {
|
|
83
|
+
const T = FEELING_WEEKS_TUNABLES;
|
|
84
|
+
if (!isDay(today)) return null;
|
|
85
|
+
const span = T.WEEKS * 7;
|
|
86
|
+
const first = addDays(today, -(span - 1));
|
|
87
|
+
const zone = store.zone();
|
|
88
|
+
const rows = new Map<string, (MemoryRow & { feeling_peak?: number | null }) | null>();
|
|
89
|
+
const lived = (id: string): (MemoryRow & { feeling_peak?: number | null }) | null => {
|
|
90
|
+
if (!rows.has(id)) {
|
|
91
|
+
const r = store.row(id);
|
|
92
|
+
rows.set(id, r === undefined || r.source === "dreamed" || r.source === "reflection" ? null : r);
|
|
93
|
+
}
|
|
94
|
+
return rows.get(id) ?? null;
|
|
95
|
+
};
|
|
96
|
+
type Hit = { memory: string; whose: "self" | "owner"; core: string; week: number; strength: number; own: boolean };
|
|
97
|
+
const hits: Hit[] = [];
|
|
98
|
+
const back: { self: Record<string, number>; owner: Record<string, number> } = { self: {}, owner: {} };
|
|
99
|
+
for (const f of store.feelingsLive()) {
|
|
100
|
+
if (!COUNTED_SOURCES.has(f.source ?? null)) continue;
|
|
101
|
+
if (f.whose !== "self" && f.whose !== "owner") continue;
|
|
102
|
+
const day = localDate(f.created_at, zone);
|
|
103
|
+
if (day < first || day > today) continue;
|
|
104
|
+
if (lived(f.memory_id) === null) continue;
|
|
105
|
+
const ago = daysBetween(day, today);
|
|
106
|
+
const week = T.WEEKS - 1 - Math.floor(ago / 7);
|
|
107
|
+
if (week < 0 || week >= T.WEEKS) continue;
|
|
108
|
+
hits.push({ memory: f.memory_id, whose: f.whose, core: f.core, week, strength: f.strength, own: f.source === OWN });
|
|
109
|
+
if (LATER.has(f.source ?? null)) back[f.whose][f.core] = (back[f.whose][f.core] ?? 0) + 1;
|
|
110
|
+
}
|
|
111
|
+
if (hits.length === 0) return null;
|
|
112
|
+
|
|
113
|
+
const tally = (whose: "self" | "owner", withOwn = true): Map<string, number[]> => {
|
|
114
|
+
const out = new Map<string, number[]>();
|
|
115
|
+
for (const h of hits) {
|
|
116
|
+
if (h.whose !== whose || (!withOwn && h.own)) continue;
|
|
117
|
+
const counts = out.get(h.core) ?? new Array<number>(T.WEEKS).fill(0);
|
|
118
|
+
counts[h.week] = (counts[h.week] ?? 0) + 1;
|
|
119
|
+
out.set(h.core, counts);
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
};
|
|
123
|
+
const sum = (xs: readonly number[]): number => xs.reduce((n, x) => n + x, 0);
|
|
124
|
+
const top = (m: Map<string, number[]>): Record<string, number[]> =>
|
|
125
|
+
Object.fromEntries([...m].sort((a, b) => sum(b[1]) - sum(a[1]) || (a[0] < b[0] ? -1 : 1)).slice(0, T.CORES_SHOWN));
|
|
126
|
+
const mineAll = tally("self");
|
|
127
|
+
const ownerAll = tally("owner");
|
|
128
|
+
|
|
129
|
+
// WHAT CHANGED: the last two windows against the two before.
|
|
130
|
+
const half = Math.floor(T.WEEKS / 2);
|
|
131
|
+
type Change = { whose: "self" | "owner"; core: string; before: number; recent: number; up: boolean };
|
|
132
|
+
const changes: Change[] = [];
|
|
133
|
+
for (const [whose, m] of [["self", tally("self", false)], ["owner", tally("owner", false)]] as const) {
|
|
134
|
+
for (const [core, counts] of m) {
|
|
135
|
+
const before = sum(counts.slice(0, half));
|
|
136
|
+
const recent = sum(counts.slice(half));
|
|
137
|
+
if (recent >= before + T.MIN_CHANGE && recent >= 2 * before) changes.push({ whose, core, before, recent, up: true });
|
|
138
|
+
else if (before >= recent + T.MIN_CHANGE && before >= 2 * recent) changes.push({ whose, core, before, recent, up: false });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
changes.sort((a, b) => Math.abs(b.recent - b.before) - Math.abs(a.recent - a.before) || (a.whose < b.whose ? 1 : -1) || (a.core < b.core ? -1 : 1));
|
|
142
|
+
const shownChanges = changes.slice(0, T.CHANGED);
|
|
143
|
+
const changed = shownChanges.map(
|
|
144
|
+
(c) => `${c.whose === "self" ? "my" : "the owner's"} ${c.core} ${c.up ? "up" : "down"}: ${String(c.before)} in the two weeks before, ${String(c.recent)} in the last two`,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// WHAT IT RESTS ON: the strongest feelings behind each change (recent ones
|
|
148
|
+
// for a rise, earlier ones for a fall); with no change, behind my commonest
|
|
149
|
+
// core of the span. Only what the reflection may cite.
|
|
150
|
+
const restsOn: string[] = [];
|
|
151
|
+
const add = (pick: (h: Hit) => boolean, n: number): void => {
|
|
152
|
+
const ranked = hits.filter(pick).sort((a, b) => b.strength - a.strength || b.week - a.week || (a.memory < b.memory ? -1 : 1));
|
|
153
|
+
let took = 0;
|
|
154
|
+
for (const h of ranked) {
|
|
155
|
+
if (restsOn.length >= T.RESTS_ON || took >= n) return;
|
|
156
|
+
if (restsOn.includes(h.memory)) continue;
|
|
157
|
+
const r = lived(h.memory);
|
|
158
|
+
if (r === null || !citable(r)) continue;
|
|
159
|
+
restsOn.push(h.memory);
|
|
160
|
+
took += 1;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
for (const c of shownChanges) add((h) => !h.own && h.whose === c.whose && h.core === c.core && (c.up ? h.week >= half : h.week < half), T.PER_CHANGE);
|
|
164
|
+
if (shownChanges.length === 0) {
|
|
165
|
+
const commonest = [...mineAll].sort((a, b) => sum(b[1]) - sum(a[1]) || (a[0] < b[0] ? -1 : 1))[0]?.[0];
|
|
166
|
+
if (commonest !== undefined) add((h) => h.whose === "self" && h.core === commonest, T.PER_CHANGE);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
weeks: Array.from({ length: T.WEEKS }, (_, i) => addDays(first, i * 7)),
|
|
171
|
+
mine: top(mineAll),
|
|
172
|
+
owner: top(ownerAll),
|
|
173
|
+
lookingBack: { mine: back.self, owner: back.owner },
|
|
174
|
+
changed,
|
|
175
|
+
restsOn,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* AWAKE LATER FEELINGS, COUNTED (2026-10-02, review of #316, item 8): the way
|
|
181
|
+
* from an ordinary session to the core's fast lane is kept loose (the owner's
|
|
182
|
+
* rule: few guards, tighten after a real issue) and made VISIBLE instead. The
|
|
183
|
+
* rows are the durable record (`source = awake`); this reads them on live
|
|
184
|
+
* memories — how many, how many at the fast lane's strength
|
|
185
|
+
* (`CORE_FAST_FEELING`), how many the owner's. Doctor's Reflection line says it.
|
|
186
|
+
*/
|
|
187
|
+
export function awakeFeelingCounts(store: Pick<Store, "feelingsLive">): { total: number; fast: number; owner: number } {
|
|
188
|
+
let total = 0;
|
|
189
|
+
let fast = 0;
|
|
190
|
+
let owner = 0;
|
|
191
|
+
for (const f of store.feelingsLive()) {
|
|
192
|
+
if (f.source !== "awake") continue;
|
|
193
|
+
total += 1;
|
|
194
|
+
if (f.strength >= PHYSICS_TUNABLES.CORE_FAST_FEELING) fast += 1;
|
|
195
|
+
if (f.whose === "owner") owner += 1;
|
|
196
|
+
}
|
|
197
|
+
return { total, fast, owner };
|
|
198
|
+
}
|