counterparts 0.3.0 → 0.3.2
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 +76 -0
- package/docs/module-map.md +2 -0
- package/package.json +2 -1
- package/src/adapters/claude-code/CONTRACT.md +2 -1
- package/src/adapters/claude-code/NOTES.md +90 -2
- package/src/adapters/claude-code/bin/hook.ts +17 -2
- package/src/adapters/claude-code/bin/runner.ts +4 -1
- package/src/adapters/claude-code/config.ts +23 -0
- package/src/adapters/claude-code/doctor.ts +148 -26
- package/src/adapters/claude-code/hooks.ts +37 -12
- package/src/adapters/claude-code/index.ts +2 -0
- package/src/adapters/claude-code/standdown.ts +12 -1
- package/src/adapters/claude-code/transcript.ts +79 -6
- package/src/adapters/cli/INTERFACE-GAPS.md +4 -0
- package/src/adapters/cli/commands.ts +209 -61
- package/src/adapters/cli/export.ts +27 -3
- package/src/adapters/cli/help.ts +22 -8
- package/src/adapters/cli/install.ts +3 -5
- package/src/adapters/cli/mechanisms.ts +295 -0
- package/src/adapters/cli/repair-dates.ts +3 -1
- package/src/adapters/cli/snapshot.ts +4 -27
- package/src/adapters/dashboard/CONTRACT.md +13 -9
- package/src/adapters/dashboard/INTERFACE-GAPS.md +4 -0
- package/src/adapters/dashboard/NOTES.md +3 -2
- package/src/adapters/dashboard/activity.ts +2 -1
- package/src/adapters/dashboard/bin/dashboard.ts +18 -3
- package/src/adapters/dashboard/upgrade.ts +23 -0
- package/src/adapters/dashboard/web/README.md +153 -0
- package/src/adapters/dashboard/web/actions.ts +631 -0
- package/src/adapters/dashboard/web/app.html +40 -1703
- package/src/adapters/dashboard/web/app.js +55 -0
- package/src/adapters/dashboard/web/mechanisms/association/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/association/panel.js +17 -0
- package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +23 -0
- package/src/adapters/dashboard/web/mechanisms/decay/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/decay/panel.js +45 -0
- package/src/adapters/dashboard/web/mechanisms/emotional/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/index.js +60 -0
- package/src/adapters/dashboard/web/mechanisms/interference/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/picture.js +28 -0
- package/src/adapters/dashboard/web/mechanisms/prospective/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/regions.js +30 -0
- package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +20 -0
- package/src/adapters/dashboard/web/mechanisms/salience/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/salience/panel.js +14 -0
- package/src/adapters/dashboard/web/mechanisms/schema/index.js +15 -0
- package/src/adapters/dashboard/web/narrate.ts +10 -10
- package/src/adapters/dashboard/web/pages/flow/flow.css +38 -0
- package/src/adapters/dashboard/web/pages/flow/index.js +117 -0
- package/src/adapters/dashboard/web/pages/flow/sections/blind.js +12 -0
- package/src/adapters/dashboard/web/pages/flow/sections/detail.js +45 -0
- package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +291 -0
- package/src/adapters/dashboard/web/pages/flow/sections/feed.js +11 -0
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +41 -0
- package/src/adapters/dashboard/web/pages/flow/sections/heatmap.js +25 -0
- package/src/adapters/dashboard/web/pages/flow/sections/records.js +24 -0
- package/src/adapters/dashboard/web/pages/flow/sections/symmetry.js +17 -0
- package/src/adapters/dashboard/web/pages/flow/state.js +3 -0
- package/src/adapters/dashboard/web/pages/health/health.css +93 -0
- package/src/adapters/dashboard/web/pages/health/index.js +41 -0
- package/src/adapters/dashboard/web/pages/health/sections/archive.js +84 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +172 -0
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +37 -0
- package/src/adapters/dashboard/web/pages/health/sections/verify.js +54 -0
- package/src/adapters/dashboard/web/pages/home/brain.js +375 -0
- package/src/adapters/dashboard/web/pages/home/home.css +134 -0
- package/src/adapters/dashboard/web/pages/home/index.js +84 -0
- package/src/adapters/dashboard/web/pages/home/sections/explorer.js +206 -0
- package/src/adapters/dashboard/web/pages/home/sections/hero.js +22 -0
- package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +25 -0
- package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +13 -0
- package/src/adapters/dashboard/web/pages/home/sections/tiles.js +52 -0
- package/src/adapters/dashboard/web/pages/memories/index.js +75 -0
- package/src/adapters/dashboard/web/pages/memories/memories.css +143 -0
- package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +178 -0
- package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +42 -0
- package/src/adapters/dashboard/web/pages/memories/sections/list.js +114 -0
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +102 -0
- package/src/adapters/dashboard/web/pages/memories/sections/tools.js +155 -0
- package/src/adapters/dashboard/web/pages/memories/state.js +22 -0
- package/src/adapters/dashboard/web/pages/self/diff.js +79 -0
- package/src/adapters/dashboard/web/pages/self/index.js +43 -0
- package/src/adapters/dashboard/web/pages/self/markdown.js +61 -0
- package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -0
- package/src/adapters/dashboard/web/pages/self/sections/page.js +149 -0
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +150 -0
- package/src/adapters/dashboard/web/pages/self/sections/stories.js +47 -0
- package/src/adapters/dashboard/web/pages/self/sections/wake.js +74 -0
- package/src/adapters/dashboard/web/pages/self/self.css +182 -0
- package/src/adapters/dashboard/web/server.ts +305 -28
- package/src/adapters/dashboard/web/shared/absence.js +14 -0
- package/src/adapters/dashboard/web/shared/actions.js +48 -0
- package/src/adapters/dashboard/web/shared/api.js +17 -0
- package/src/adapters/dashboard/web/shared/base.css +34 -0
- package/src/adapters/dashboard/web/shared/canvas.js +68 -0
- package/src/adapters/dashboard/web/shared/colors.js +6 -0
- package/src/adapters/dashboard/web/shared/dom.js +4 -0
- package/src/adapters/dashboard/web/shared/event-modal.js +25 -0
- package/src/adapters/dashboard/web/shared/fonts/OFL-courier-prime.txt +93 -0
- package/src/adapters/dashboard/web/shared/fonts/OFL-outfit.txt +93 -0
- package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-400.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-700.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/fonts/outfit-latin-wght.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/format.js +31 -0
- package/src/adapters/dashboard/web/shared/layout.css +32 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +124 -0
- package/src/adapters/dashboard/web/shared/modal.css +24 -0
- package/src/adapters/dashboard/web/shared/modal.js +22 -0
- package/src/adapters/dashboard/web/shared/state.js +12 -0
- package/src/adapters/dashboard/web/shared/tip.css +4 -0
- package/src/adapters/dashboard/web/shared/tip.js +12 -0
- package/src/adapters/dashboard/web/shared/tokens.css +50 -0
- package/src/adapters/dashboard/web/shared/type.css +52 -0
- package/src/adapters/dashboard/web/shared/utilities.css +5 -0
- package/src/adapters/dashboard/web/shared/vendor/MIT-three.txt +21 -0
- package/src/adapters/dashboard/web/shared/vendor/three.module.min.js +6 -0
- package/src/adapters/dashboard/web/shared/widgets/bar.css +9 -0
- package/src/adapters/dashboard/web/shared/widgets/card.css +6 -0
- package/src/adapters/dashboard/web/shared/widgets/chapters.js +15 -0
- package/src/adapters/dashboard/web/shared/widgets/chart.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/confirm.css +31 -0
- package/src/adapters/dashboard/web/shared/widgets/confirm.js +52 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.css +13 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.js +41 -0
- package/src/adapters/dashboard/web/shared/widgets/light.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/light.js +15 -0
- package/src/adapters/dashboard/web/shared/widgets/rows.css +7 -0
- package/src/adapters/dashboard/web/shared/widgets/table.css +17 -0
- package/src/adapters/dashboard/web/shared/widgets/tiles.css +14 -0
- package/src/adapters/dashboard/web/shell/pages.js +15 -0
- package/src/adapters/dashboard/web/shell/pulse.js +86 -0
- package/src/adapters/dashboard/web/shell/tabs.js +49 -0
- package/src/adapters/dashboard/web/static.ts +76 -0
- package/src/adapters/dashboard/web/views/activity.ts +80 -0
- package/src/adapters/dashboard/web/views/archive-words.ts +57 -0
- package/src/adapters/dashboard/web/views/flow-view.ts +217 -0
- package/src/adapters/dashboard/web/views/health.ts +328 -0
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +370 -0
- package/src/adapters/dashboard/web/views/mechanisms.ts +302 -0
- package/src/adapters/dashboard/web/views/memories.ts +342 -0
- package/src/adapters/dashboard/web/views/memory.ts +210 -0
- package/src/adapters/dashboard/web/views/meta.ts +64 -0
- package/src/adapters/dashboard/web/views/mind.ts +729 -0
- package/src/adapters/dashboard/web/views/overview.ts +282 -0
- package/src/adapters/dashboard/web/views/pulse.ts +19 -0
- package/src/adapters/dashboard/web/views/rows.ts +207 -0
- package/src/adapters/dashboard/web/views/search.ts +62 -0
- package/src/adapters/dashboard/web/views/shared.ts +161 -0
- package/src/adapters/dashboard/web/views.ts +34 -1724
- package/src/adapters/fired.ts +138 -31
- package/src/adapters/mcp/INTERFACE-GAPS.md +4 -1
- package/src/adapters/mcp/NOTES.md +43 -0
- package/src/adapters/mcp/bin/serve.ts +9 -1
- package/src/adapters/mcp/index.ts +7 -0
- package/src/adapters/mcp/server.ts +167 -6
- package/src/adapters/mcp/tools.ts +42 -0
- package/src/adapters/mcp/write-up.ts +1 -1
- package/src/adapters/sessions.ts +18 -1
- package/src/adapters/snapshots.ts +71 -39
- package/src/core/associate/INTERFACE-GAPS.md +8 -0
- package/src/core/counterpart.ts +86 -7
- package/src/core/encode/INTERFACE-GAPS.md +12 -0
- package/src/core/feelings-wheel.ts +218 -0
- package/src/core/handoff/INTERFACE-GAPS.md +2 -0
- package/src/core/mint.ts +14 -2
- package/src/core/prospective/INTERFACE-GAPS.md +14 -0
- package/src/core/prospective/windows.ts +10 -48
- package/src/core/recall/INTERFACE-GAPS.md +6 -0
- package/src/core/remember/INTERFACE-GAPS.md +10 -0
- package/src/core/schemas/INTERFACE-GAPS.md +8 -0
- package/src/core/schemas/NOTES.md +118 -1
- package/src/core/schemas/index.ts +330 -40
- package/src/core/schemas/tunables.ts +23 -0
- package/src/core/schemas/types.ts +64 -1
- package/src/core/self/CONTRACT.md +3 -0
- package/src/core/self/INTERFACE-GAPS.md +10 -0
- package/src/core/self/NOTES.md +33 -2
- package/src/core/self/calendar.ts +7 -78
- package/src/core/self/episodes.ts +52 -12
- package/src/core/self/index.ts +40 -12
- package/src/core/self/writer.ts +22 -22
- package/src/core/sleep/NOTES.md +36 -0
- package/src/core/sleep/cycle.ts +38 -3
- package/src/core/sleep/fade.ts +76 -0
- package/src/core/sleep/index.ts +4 -1
- package/src/core/sleep/prune.ts +8 -1
- package/src/core/sleep/tunables.ts +5 -0
- package/src/core/sleep/types.ts +24 -0
- package/src/core/store/CONTRACT.md +36 -7
- package/src/core/store/NOTES.md +197 -0
- package/src/core/store/errors.ts +22 -0
- package/src/core/store/feelings.ts +182 -0
- package/src/core/store/index.ts +339 -45
- package/src/core/store/operational.ts +240 -22
- package/src/core/store/owner-op-seam.ts +13 -3
- package/src/core/store/paths.ts +15 -1
- package/src/core/store/pre-migration.ts +258 -0
- package/src/core/store/prose.ts +8 -1
- package/src/core/store/render.ts +3 -0
- package/src/core/time.ts +374 -0
- package/src/core/types.ts +13 -0
- package/src/adapters/dashboard/web/brain.html +0 -463
|
@@ -5,6 +5,8 @@ entry names the owner, the workaround now in the code, and what the real fix loo
|
|
|
5
5
|
|
|
6
6
|
## 0. The identity core's home row — `schemas/`'s requirement, ADOPTED with one caveat
|
|
7
7
|
|
|
8
|
+
**Closed 2026-09-24** — the owed seam test is `test/seams.test.ts` (mints via `ensureIdentityCore`, asserts `status-on-identity-refused`).
|
|
9
|
+
|
|
8
10
|
**Owner:** this module (`schemas/INTERFACE-GAPS.md` §5 filed it here, mid-build).
|
|
9
11
|
**Needed:** `schemas/` refuses to birth `kind: "self"` in two independent layers, so the
|
|
10
12
|
row that says *the self exists as an entity here* can only come from `self/`. Without it,
|
|
@@ -86,6 +88,8 @@ wake path. A read that is not a delivery still pays exactly one meta row.
|
|
|
86
88
|
|
|
87
89
|
## 3. `prospective/` does not exist — the horizon is caller-supplied
|
|
88
90
|
|
|
91
|
+
**Closed 2026-09-24** — `Prospective.horizon()` feeds the lane through `core/briefing.ts`.
|
|
92
|
+
|
|
89
93
|
**Owner:** `prospective/`.
|
|
90
94
|
**Needed:** "arriving occasions" is a briefing lane (behavioral-spec §1, contract §5
|
|
91
95
|
INPUTS: *the prospective horizon*).
|
|
@@ -118,6 +122,8 @@ which is the same two lines.
|
|
|
118
122
|
|
|
119
123
|
## 5. The episode gate is injected, and its default REFUSES
|
|
120
124
|
|
|
125
|
+
**Closed 2026-09-24** — `core/bridge.ts#episodeGate` is wired in `counterpart.ts`, so the refusing default is unreachable in production.
|
|
126
|
+
|
|
121
127
|
**Owner:** `encode/` (the gate battery: secrets, precision, the emotion exemption).
|
|
122
128
|
**Needed:** "ingestion is ordinary and the gates apply — a first-person reflection is not
|
|
123
129
|
exempt from never durably encoding a credential" (contract §3, scar §2.7: episode
|
|
@@ -134,6 +140,8 @@ distinguishes "refused by the real gate" from "nobody wired one".
|
|
|
134
140
|
|
|
135
141
|
## 6. `sleep/` expects a `RenderFn`; `Self.boundary` is it, minus the budget
|
|
136
142
|
|
|
143
|
+
**Closed 2026-09-24** — `budgetBytes` is a cycle option (`sleep/cycle.ts`) passed to `runBriefing`.
|
|
144
|
+
|
|
137
145
|
**Owner:** the coordinator (both modules were built in parallel and neither imports the
|
|
138
146
|
other — `sleep/briefing.ts` says so in its header, and a test on each side asserts it).
|
|
139
147
|
**Needed:** the re-render must be the cycle's LAST content write, after revision, so it
|
|
@@ -155,6 +163,8 @@ under-floor ceiling fires `self.briefing.overbudget` at every boundary.
|
|
|
155
163
|
|
|
156
164
|
## 7. Reference resolution for confirmations has no caller yet
|
|
157
165
|
|
|
166
|
+
**Closed 2026-09-24** — `core/mint.ts` routes a self-claim confirmation to `self.noteSelfConfirmation`.
|
|
167
|
+
|
|
158
168
|
`Self.noteSelfConfirmation` is the freeze seam: whoever decides that a fallback sweep has
|
|
159
169
|
produced a confirmation against an existing element calls it, and it resolves, decides,
|
|
160
170
|
counts and (only in the live arm) reinforces. Deciding *that* — which claim in a sweep is
|
package/src/core/self/NOTES.md
CHANGED
|
@@ -1151,7 +1151,7 @@ and `askDue`/`noteOrphanTail` read the same re-based state. Any other reading be
|
|
|
1151
1151
|
watermark — an empty one from a transcript that would not read — moves nothing, and a
|
|
1152
1152
|
caller can say its count is not real with `rebase: false`.
|
|
1153
1153
|
|
|
1154
|
-
## 24. A chapter's heading carries its calendar date (2026-09-24)
|
|
1154
|
+
## 24. A chapter's heading carries its calendar date, and the model that wrote it (2026-09-24)
|
|
1155
1155
|
|
|
1156
1156
|
`chapterHeading` writes `## chapter 1 — Wed 23 Sep 2026 · lived day 2` for every chapter
|
|
1157
1157
|
opened since this date, where it wrote `## chapter 1 — lived day 2` before. The owner
|
|
@@ -1165,7 +1165,21 @@ model sometimes writes under the journal's own — for a surface that shows a ch
|
|
|
1165
1165
|
words on one line and its heading as metadata. Every surface that prints the body
|
|
1166
1166
|
inherits the new heading with no change of its own; none of them parses it.
|
|
1167
1167
|
|
|
1168
|
-
|
|
1168
|
+
**Built the same day: each chapter records the model that wrote it.** The heading reads
|
|
1169
|
+
`## chapter 1 — Wed 23 Sep 2026 · claude-opus-5-5 · lived day 2`, and the episode's
|
|
1170
|
+
`meta.models` maps chapter number to model id (`{ "1": "claude-opus-5-5" }`), written
|
|
1171
|
+
when a chapter opens and carried whole on every revise (meta merges shallowly). The
|
|
1172
|
+
path is the one below: `parseTranscript` takes the last assistant `message.model` that
|
|
1173
|
+
is not a host stand-in (`<synthetic>`, `isApiErrorMessage`) or a sidechain → the
|
|
1174
|
+
record's `model` (carried like `config`, newest wins; `isModelId` screens it, since it
|
|
1175
|
+
is printed into a heading) → `chapterTool` → `appendEpisode({ model })`. The Stop writes
|
|
1176
|
+
the record before its ask goes out, so the chapter that answers the ask has the right
|
|
1177
|
+
model. Unknown model: the heading is the dated form, nothing added. `ask`'s meta line
|
|
1178
|
+
shows it after the date; the dashboard's journal list shows no date and was left alone.
|
|
1179
|
+
Raw ids are printed as the host reports them.
|
|
1180
|
+
|
|
1181
|
+
The original note, kept for the reasoning: which MODEL wrote a chapter was not recorded
|
|
1182
|
+
(asked the same day). It needs no schema
|
|
1169
1183
|
migration — the episode's `meta` is open JSON — but this package does not know the model
|
|
1170
1184
|
at the door that writes a chapter: `chapter` is an MCP tool, and the MCP server has no
|
|
1171
1185
|
hook input and no transcript. The host's only sources are the SessionStart input's
|
|
@@ -1177,3 +1191,20 @@ record (`adapters/sessions.ts`, optional fields already) → `mcp/server.ts#chap
|
|
|
1177
1191
|
reads that record, as `corroborate` already does → `appendEpisode` opts → `meta` per
|
|
1178
1192
|
chapter. It lags a mid-session `/model` switch by one turn (the record is refreshed at
|
|
1179
1193
|
the boundary, and this adapter registers no `PostModelSwitch` hook).
|
|
1194
|
+
|
|
1195
|
+
## 25. One calendar for the self and the store (2026-09-25)
|
|
1196
|
+
|
|
1197
|
+
docs/time.md moved `learned_on` to the local day, in the STORE's zone (`Store#zone`: the
|
|
1198
|
+
config's `timeZone`, else the machine's). §22's "two clocks in one store" is therefore one
|
|
1199
|
+
clock from this date: `Self` with no `zone` of its own now uses the store's
|
|
1200
|
+
(`dayZone()`), and `pageWriterNight` passes the store's own yesterday as `closedThrough`,
|
|
1201
|
+
which in one zone IS the local yesterday — so §22's east-of-UTC guard reduces to the plain
|
|
1202
|
+
rule. It is kept, because it still does the right thing for a `Self` pinned to a zone apart
|
|
1203
|
+
from its store's (the tests in `test/local-day.test.ts` pin the store to UTC to keep
|
|
1204
|
+
proving it). For the nights either side of the change, rows written before carry a UTC
|
|
1205
|
+
`learned_on`, so a row may be read one night early or late — never twice or not at all.
|
|
1206
|
+
|
|
1207
|
+
`calendar.ts` is now a re-export of `core/time.ts`, and `isModelId` of `core/types.ts`;
|
|
1208
|
+
no caller moved. The self page and each chapter's episode row also record their writer in
|
|
1209
|
+
the store's `model` column (store NOTES 2026-09-25) beside `meta.models`.
|
|
1210
|
+
|
|
@@ -1,81 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* THE CALENDAR DAY A PERSON LIVES ON —
|
|
2
|
+
* THE CALENDAR DAY A PERSON LIVES ON — moved to `core/time.ts` (2026-09-25).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* a day again").
|
|
10
|
-
*
|
|
11
|
-
* **What this does NOT move.** Two other clocks stay exactly where they were:
|
|
12
|
-
*
|
|
13
|
-
* - the LIVED day (`store.livedDay()`), the physics clock, which counts days
|
|
14
|
-
* actually lived and is advanced only by the sleep cycle — nothing here
|
|
15
|
-
* reads or writes it;
|
|
16
|
-
* - the PROVENANCE date (`store.today()`, `learned_on`, `revisedOn`, every
|
|
17
|
-
* `date` a hook stamps), which is `store/`'s and stays UTC by the decision
|
|
18
|
-
* `store/index.ts#dateOf` records. The page writer still SELECTS a day's
|
|
19
|
-
* memories by `learned_on`, so the day it names (local) and the day it reads
|
|
20
|
-
* (UTC-stamped) are offset by the zone — every memory is still read exactly
|
|
21
|
-
* once, on the run after its UTC date closes (self NOTES §22).
|
|
22
|
-
*
|
|
23
|
-
* The INSTANT is the store's provenance clock (`store.now()`), never the ambient
|
|
24
|
-
* `Date.now`: a seeded, replayed or migrated store decides its days by the run it
|
|
25
|
-
* is replaying, exactly as it dates its rows.
|
|
26
|
-
*
|
|
27
|
-
* `zone` is an IANA name (`"America/Chicago"`, `"UTC"`). Absent, the machine's
|
|
28
|
-
* own zone decides — which is what `TZ` sets for a process. It exists so a test
|
|
29
|
-
* can pin the zone and pass on any machine, not as an owner-facing setting.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/** `YYYY-MM-DD` for `at` (ms since the epoch) in `zone`, or the machine's zone. */
|
|
33
|
-
export function calendarDate(at: number, zone?: string): string {
|
|
34
|
-
const d = new Date(at);
|
|
35
|
-
if (!Number.isFinite(d.getTime())) return "";
|
|
36
|
-
if (zone === undefined) {
|
|
37
|
-
// The machine's zone: the Date getters read it, and so does `TZ`.
|
|
38
|
-
return `${String(d.getFullYear()).padStart(4, "0")}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
39
|
-
}
|
|
40
|
-
let parts: Intl.DateTimeFormatPart[];
|
|
41
|
-
try {
|
|
42
|
-
parts = new Intl.DateTimeFormat("en-US", {
|
|
43
|
-
timeZone: zone,
|
|
44
|
-
year: "numeric",
|
|
45
|
-
month: "2-digit",
|
|
46
|
-
day: "2-digit",
|
|
47
|
-
}).formatToParts(d);
|
|
48
|
-
} catch {
|
|
49
|
-
// An unknown zone name is a caller's mistake, and the safe reading of it is
|
|
50
|
-
// the machine's own day rather than a throw inside a hook.
|
|
51
|
-
return calendarDate(at);
|
|
52
|
-
}
|
|
53
|
-
const part = (type: string): string => parts.find((p) => p.type === type)?.value ?? "";
|
|
54
|
-
return `${part("year").padStart(4, "0")}-${part("month")}-${part("day")}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function pad2(n: number): string {
|
|
58
|
-
return String(n).padStart(2, "0");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] as const;
|
|
62
|
-
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] as const;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* A `YYYY-MM-DD` as a person reads it: `Tue 23 Sep 2026`. Empty for anything
|
|
66
|
-
* that is not a whole, real date — a `2026-08` precision or a typo is not
|
|
67
|
-
* padded into a day it never named.
|
|
68
|
-
*
|
|
69
|
-
* The string is ALREADY a calendar day (whichever zone decided it), so it is
|
|
70
|
-
* read as that day and nothing else: built at UTC midnight and read back with
|
|
71
|
-
* the UTC getters, so a machine west of Greenwich does not name the weekday
|
|
72
|
-
* before it.
|
|
4
|
+
* This file was B3's local-day helper (owner's ruling 2026-09-23: the ask cap
|
|
5
|
+
* and the nightly page writer take their day in the machine's LOCAL zone; self
|
|
6
|
+
* NOTES §22). docs/time.md then made one module own every conversion, and that
|
|
7
|
+
* module is `core/time.ts`. The two names this file exported stay importable
|
|
8
|
+
* from here and from `self/index.ts`, so no caller had to move.
|
|
73
9
|
*/
|
|
74
|
-
export
|
|
75
|
-
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(ymd.trim());
|
|
76
|
-
if (m === null) return "";
|
|
77
|
-
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
78
|
-
const at = new Date(Date.UTC(y, mo - 1, d));
|
|
79
|
-
if (at.getUTCFullYear() !== y || at.getUTCMonth() !== mo - 1 || at.getUTCDate() !== d) return "";
|
|
80
|
-
return `${WEEKDAYS[at.getUTCDay()]} ${String(d)} ${MONTHS[mo - 1]} ${String(y)}`;
|
|
81
|
-
}
|
|
10
|
+
export { calendarDate, readableDate } from "../time.js";
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
* fires).
|
|
40
40
|
*/
|
|
41
41
|
import type { Salience } from "../types.js";
|
|
42
|
+
import { isModelId } from "../types.js";
|
|
42
43
|
import type { ProseDoc, Store } from "../store/index.js";
|
|
43
44
|
import { hashText } from "../store/index.js";
|
|
44
45
|
import type { SelfTunables } from "./tunables.js";
|
|
@@ -428,12 +429,30 @@ export function askText(chapter: number): string {
|
|
|
428
429
|
* heading is the older form, `## chapter 1 — lived day 2`, which every chapter
|
|
429
430
|
* written before 2026-09-24 still carries — stored bodies are never rewritten,
|
|
430
431
|
* and `readChapterLead` reads both.
|
|
432
|
+
*
|
|
433
|
+
* `model` is the model that wrote the chapter, printed raw after the date —
|
|
434
|
+
* `## chapter 1 — Tue 23 Sep 2026 · claude-opus-5-5 · lived day 2`. Unknown,
|
|
435
|
+
* it is left out.
|
|
431
436
|
*/
|
|
432
|
-
export function chapterHeading(chapter: number, day: number, date?: string): string {
|
|
437
|
+
export function chapterHeading(chapter: number, day: number, date?: string, model?: string): string {
|
|
433
438
|
const said = date === undefined ? "" : readableDate(date);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
439
|
+
const by = model !== undefined && isModelId(model) ? model : "";
|
|
440
|
+
const parts = [said, by].filter((p) => p.length > 0);
|
|
441
|
+
return `## chapter ${chapter} — ${[...parts, `lived day ${day}`].join(" · ")}`;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** The model-id screen lives in `core/types.ts` now (2026-09-25); re-exported. */
|
|
445
|
+
export { isModelId };
|
|
446
|
+
|
|
447
|
+
/** Which model wrote each chapter, from an episode's meta — `{ "1": "claude-opus-5-5" }`. */
|
|
448
|
+
export function chapterModels(meta: Record<string, unknown>): Record<string, string> {
|
|
449
|
+
const raw = meta["models"];
|
|
450
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
451
|
+
const out: Record<string, string> = {};
|
|
452
|
+
for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {
|
|
453
|
+
if (/^\d+$/.test(k) && isModelId(v)) out[k] = v;
|
|
454
|
+
}
|
|
455
|
+
return out;
|
|
437
456
|
}
|
|
438
457
|
|
|
439
458
|
/** What the headings at the top of a chapter's text said, and the text after them. */
|
|
@@ -444,6 +463,8 @@ export interface ChapterLead {
|
|
|
444
463
|
readonly livedDay: number | null;
|
|
445
464
|
/** The first calendar date the leading headings named, as written (`Tue 23 Sep 2026`), or null. */
|
|
446
465
|
readonly date: string | null;
|
|
466
|
+
/** The first model the leading headings named (`claude-opus-5-5`), or null. */
|
|
467
|
+
readonly model: string | null;
|
|
447
468
|
/** The text with the LEADING headings taken off — however many were stacked. */
|
|
448
469
|
readonly rest: string;
|
|
449
470
|
}
|
|
@@ -455,7 +476,7 @@ export interface ChapterLead {
|
|
|
455
476
|
* Mike opened…`).
|
|
456
477
|
*/
|
|
457
478
|
const LEAD_HEADING =
|
|
458
|
-
/^\s*#{1,6}[ \t]*chapter[ \t]+(\d+)(?:[ \t]*[—–-][ \t]*(?:([A-Za-z]{3} \d{1,2} [A-Za-z]{3} \d{4})[ \t]*·[ \t]*)?lived day[ \t]+(\d+))?[ \t]*(?:\n|$)/i;
|
|
479
|
+
/^\s*#{1,6}[ \t]*chapter[ \t]+(\d+)(?:[ \t]*[—–-][ \t]*(?:([A-Za-z]{3} \d{1,2} [A-Za-z]{3} \d{4})[ \t]*·[ \t]*)?(?:([A-Za-z0-9][A-Za-z0-9._:[\]-]*)[ \t]*·[ \t]*)?lived day[ \t]+(\d+))?[ \t]*(?:\n|$)/i;
|
|
459
480
|
const ANY_HEADING = /^[ \t]*#{1,6}[ \t]*chapter[ \t]+(\d+)\b/gim;
|
|
460
481
|
|
|
461
482
|
/**
|
|
@@ -469,14 +490,16 @@ export function readChapterLead(text: string): ChapterLead {
|
|
|
469
490
|
let rest = text;
|
|
470
491
|
let livedDay: number | null = null;
|
|
471
492
|
let date: string | null = null;
|
|
493
|
+
let model: string | null = null;
|
|
472
494
|
for (let m = LEAD_HEADING.exec(rest); m !== null; m = LEAD_HEADING.exec(rest)) {
|
|
473
|
-
if (livedDay === null && m[
|
|
495
|
+
if (livedDay === null && m[4] !== undefined) livedDay = Number(m[4]);
|
|
474
496
|
if (date === null && m[2] !== undefined) date = m[2];
|
|
497
|
+
if (model === null && m[3] !== undefined) model = m[3];
|
|
475
498
|
rest = rest.slice(m[0].length);
|
|
476
499
|
}
|
|
477
500
|
const seen = new Set<number>();
|
|
478
501
|
for (const m of text.matchAll(ANY_HEADING)) seen.add(Number(m[1]));
|
|
479
|
-
return { chapters: [...seen].sort((a, b) => a - b), livedDay, date, rest: rest.trimStart() };
|
|
502
|
+
return { chapters: [...seen].sort((a, b) => a - b), livedDay, date, model, rest: rest.trimStart() };
|
|
480
503
|
}
|
|
481
504
|
|
|
482
505
|
/**
|
|
@@ -496,11 +519,12 @@ export function appendChapter(
|
|
|
496
519
|
store: Store,
|
|
497
520
|
state: EpisodeState,
|
|
498
521
|
text: string,
|
|
499
|
-
opts: { day: number; date?: string; title?: string; happenedOn?: string },
|
|
522
|
+
opts: { day: number; date?: string; model?: string; title?: string; happenedOn?: string },
|
|
500
523
|
): { episodeId: string; chapter: number; created: boolean; heading: boolean } {
|
|
501
524
|
const opens = state.episodeId === null || state.asks > state.appendedAtAsk;
|
|
502
525
|
const chapter = opens ? state.chapters + 1 : Math.max(1, state.chapters);
|
|
503
|
-
const
|
|
526
|
+
const model = isModelId(opts.model) ? opts.model : undefined;
|
|
527
|
+
const heading = chapterHeading(chapter, opts.day, opts.date, model);
|
|
504
528
|
const body = `${heading}\n\n${text.trim()}\n`;
|
|
505
529
|
|
|
506
530
|
if (state.episodeId === null) {
|
|
@@ -509,11 +533,17 @@ export function appendChapter(
|
|
|
509
533
|
type: "episode",
|
|
510
534
|
kind: "self",
|
|
511
535
|
body,
|
|
512
|
-
meta: {
|
|
536
|
+
meta: {
|
|
537
|
+
sessionId: state.sessionId,
|
|
538
|
+
chapters: chapter,
|
|
539
|
+
...(model === undefined ? {} : { models: { [String(chapter)]: model } }),
|
|
540
|
+
},
|
|
513
541
|
// The experiencer writing its own journal is the "episode" channel —
|
|
514
542
|
// consistent with the memory its ingestion mints (PR-2 review nit).
|
|
515
543
|
source: "episode",
|
|
516
544
|
origin: { session: state.sessionId },
|
|
545
|
+
// The row's `model` column (schema v7) as well as the chapter's meta.
|
|
546
|
+
...(model === undefined ? {} : { model }),
|
|
517
547
|
};
|
|
518
548
|
if (opts.title !== undefined) input.title = opts.title;
|
|
519
549
|
if (opts.happenedOn !== undefined) input.happenedOn = opts.happenedOn;
|
|
@@ -527,10 +557,20 @@ export function appendChapter(
|
|
|
527
557
|
// only if this chapter is genuinely past what the file already carries.
|
|
528
558
|
const opensChapter = opens && chapter > recorded;
|
|
529
559
|
const num = opensChapter ? chapter : Math.max(1, recorded);
|
|
560
|
+
// Each chapter keeps the model that opened it; meta merges shallowly, so
|
|
561
|
+
// the whole map is carried.
|
|
562
|
+
const models = chapterModels(prior.meta);
|
|
563
|
+
if (opensChapter && model !== undefined) models[String(num)] = model;
|
|
530
564
|
store.revise(state.episodeId, {
|
|
531
|
-
body: `${prior.body.trimEnd()}\n\n${opensChapter ? chapterHeading(num, opts.day, opts.date) + `\n\n${text.trim()}\n` : `${text.trim()}\n`}`,
|
|
532
|
-
meta: {
|
|
565
|
+
body: `${prior.body.trimEnd()}\n\n${opensChapter ? chapterHeading(num, opts.day, opts.date, model) + `\n\n${text.trim()}\n` : `${text.trim()}\n`}`,
|
|
566
|
+
meta: {
|
|
567
|
+
sessionId: state.sessionId,
|
|
568
|
+
chapters: Math.max(num, recorded),
|
|
569
|
+
...(Object.keys(models).length === 0 ? {} : { models }),
|
|
570
|
+
},
|
|
533
571
|
reason: opensChapter ? "episode-chapter" : "episode-append",
|
|
572
|
+
// The row's `model` is the LAST writer's (a body change with none is NULL).
|
|
573
|
+
...(model === undefined ? {} : { model }),
|
|
534
574
|
});
|
|
535
575
|
return { episodeId: state.episodeId, chapter: num, created: false, heading: opensChapter };
|
|
536
576
|
}
|
package/src/core/self/index.ts
CHANGED
|
@@ -201,11 +201,16 @@ export interface SelfOptions {
|
|
|
201
201
|
/** Episode ingestion runs the ordinary gate battery. Absent means REFUSE. */
|
|
202
202
|
gate?: EpisodeGate;
|
|
203
203
|
onEvent?: (e: SelfEvent) => void;
|
|
204
|
+
/** Told about each memory an episode ingestion mints, so the composition can
|
|
205
|
+
* credit the cards it names (schemas NOTES §15). */
|
|
206
|
+
onMemoryMinted?: (m: { id: string; title: string | null; body: string; day: number }) => void;
|
|
204
207
|
now?: () => number;
|
|
205
208
|
/**
|
|
206
209
|
* The IANA zone the CALENDAR day is taken in — the ask cap's day and the page
|
|
207
|
-
* writer's night (`
|
|
208
|
-
*
|
|
210
|
+
* writer's night (`core/time.ts`). Absent: the STORE's zone (`Store#zone`: the
|
|
211
|
+
* config's `timeZone`, else the machine's), so the day a chapter is headed
|
|
212
|
+
* with and the `learned_on` its rows carry are one calendar (2026-09-25). A
|
|
213
|
+
* test pins it so it passes on any machine.
|
|
209
214
|
*/
|
|
210
215
|
zone?: string;
|
|
211
216
|
}
|
|
@@ -420,6 +425,13 @@ export interface PageWriteOptions {
|
|
|
420
425
|
*/
|
|
421
426
|
readonly ifVersion?: number;
|
|
422
427
|
readonly day?: number;
|
|
428
|
+
/**
|
|
429
|
+
* The model writing the page, from host state (schema v7's `memories.model`;
|
|
430
|
+
* the prior version keeps the model that wrote IT). The MCP door reads it off
|
|
431
|
+
* the session registry record; the owner's console and a door with no named
|
|
432
|
+
* model leave it out, and the row records NULL.
|
|
433
|
+
*/
|
|
434
|
+
readonly model?: string;
|
|
423
435
|
}
|
|
424
436
|
|
|
425
437
|
export interface PageVersion {
|
|
@@ -458,6 +470,7 @@ export class Self {
|
|
|
458
470
|
|
|
459
471
|
private readonly gate: EpisodeGate;
|
|
460
472
|
private readonly onEvent: ((e: SelfEvent) => void) | undefined;
|
|
473
|
+
private readonly onMemoryMinted: SelfOptions["onMemoryMinted"];
|
|
461
474
|
private readonly now: () => number;
|
|
462
475
|
private readonly zone: string | undefined;
|
|
463
476
|
private readonly ring: SelfEvent[] = [];
|
|
@@ -471,20 +484,26 @@ export class Self {
|
|
|
471
484
|
this.observer = opts.store.observer;
|
|
472
485
|
this.gate = opts.gate ?? NO_GATE;
|
|
473
486
|
this.onEvent = opts.onEvent;
|
|
487
|
+
this.onMemoryMinted = opts.onMemoryMinted;
|
|
474
488
|
this.now = opts.now ?? (() => Date.now());
|
|
475
489
|
this.zone = opts.zone;
|
|
476
490
|
}
|
|
477
491
|
|
|
478
492
|
/**
|
|
479
493
|
* TODAY, AS THE PERSON LIVES IT — the calendar date in the local zone, read off
|
|
480
|
-
* the store's own provenance clock (`
|
|
481
|
-
* writer's schedule read THIS
|
|
482
|
-
* `learnedOn`, a clearing's `on`)
|
|
483
|
-
*
|
|
484
|
-
*
|
|
494
|
+
* the store's own provenance clock (`core/time.ts`). The ask cap and the page
|
|
495
|
+
* writer's schedule read THIS. Every PROVENANCE date (`revisedOn`,
|
|
496
|
+
* `learnedOn`, a clearing's `on`) reads `store.today()`, which was UTC until
|
|
497
|
+
* 2026-09-25 and is now the same local day in the store's zone — so the two
|
|
498
|
+
* agree unless a caller pinned `zone` apart from the store's.
|
|
485
499
|
*/
|
|
486
500
|
calendarToday(): string {
|
|
487
|
-
return calendarDate(this.store.now(), this.
|
|
501
|
+
return calendarDate(this.store.now(), this.dayZone());
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** The zone this `Self` names days in: its own when pinned, else the store's. */
|
|
505
|
+
private dayZone(): string {
|
|
506
|
+
return this.zone ?? this.store.zone();
|
|
488
507
|
}
|
|
489
508
|
|
|
490
509
|
// ── the briefing ─────────────────────────────────────────────────────────
|
|
@@ -861,6 +880,7 @@ export class Self {
|
|
|
861
880
|
body: text,
|
|
862
881
|
meta,
|
|
863
882
|
learnedOn: this.store.today(),
|
|
883
|
+
...(opts.model === undefined ? {} : { model: opts.model }),
|
|
864
884
|
// PROTECTED AT BIRTH — the one flag that keeps the floor prune off it
|
|
865
885
|
// (`physics#pruneVerdict` blocks on it by name). It is not a
|
|
866
886
|
// confidentiality class and it buys no exemption anywhere else.
|
|
@@ -869,7 +889,13 @@ export class Self {
|
|
|
869
889
|
version = 0;
|
|
870
890
|
} else {
|
|
871
891
|
id = existing;
|
|
872
|
-
version = this.store.revise(id, {
|
|
892
|
+
version = this.store.revise(id, {
|
|
893
|
+
body: text,
|
|
894
|
+
title: PAGE_TITLE,
|
|
895
|
+
meta,
|
|
896
|
+
reason: opts.reason,
|
|
897
|
+
...(opts.model === undefined ? {} : { model: opts.model }),
|
|
898
|
+
});
|
|
873
899
|
// A page written before this flag existed — or one whose row was minted by
|
|
874
900
|
// hand — is put beyond the prune here rather than at some later repair.
|
|
875
901
|
if (this.store.row(id)?.protected !== 1) this.store.updatePhysics(id, { protected: true });
|
|
@@ -930,7 +956,7 @@ export class Self {
|
|
|
930
956
|
// The night is ours to decide unless the caller named a day: the LOCAL
|
|
931
957
|
// calendar, held back to a provenance date that has closed (`writer.ts#
|
|
932
958
|
// pageWriterNight`). A caller that passes `today` gets the plain rule.
|
|
933
|
-
const night = opts.today === undefined ? pageWriterNight(this.store, this.
|
|
959
|
+
const night = opts.today === undefined ? pageWriterNight(this.store, this.dayZone()) : null;
|
|
934
960
|
return pageWriterDue(this.store, {
|
|
935
961
|
mode: opts.mode,
|
|
936
962
|
today: opts.today ?? (night as { today: string }).today,
|
|
@@ -1706,7 +1732,7 @@ export class Self {
|
|
|
1706
1732
|
appendChapter(
|
|
1707
1733
|
sessionId: string,
|
|
1708
1734
|
text: string,
|
|
1709
|
-
opts: { day?: number; title?: string; happenedOn?: string } = {},
|
|
1735
|
+
opts: { day?: number; title?: string; happenedOn?: string; model?: string } = {},
|
|
1710
1736
|
): ChapterAppend {
|
|
1711
1737
|
const d = opts.day ?? this.store.livedDay();
|
|
1712
1738
|
if (sessionId.trim().length === 0) {
|
|
@@ -1737,10 +1763,11 @@ export class Self {
|
|
|
1737
1763
|
// the heading prints it beside the lived day (owner, 2026-09-24).
|
|
1738
1764
|
const append: Parameters<typeof appendChapter>[3] = {
|
|
1739
1765
|
day: d,
|
|
1740
|
-
date: calendarDate(this.store.now(), this.
|
|
1766
|
+
date: calendarDate(this.store.now(), this.dayZone()),
|
|
1741
1767
|
};
|
|
1742
1768
|
if (opts.title !== undefined) append.title = opts.title;
|
|
1743
1769
|
if (opts.happenedOn !== undefined) append.happenedOn = opts.happenedOn;
|
|
1770
|
+
if (opts.model !== undefined) append.model = opts.model;
|
|
1744
1771
|
const written = appendChapter(this.store, state, gatedText, append);
|
|
1745
1772
|
this.persistState(
|
|
1746
1773
|
{
|
|
@@ -1935,6 +1962,7 @@ export class Self {
|
|
|
1935
1962
|
handles: handles.length,
|
|
1936
1963
|
bytes: byteLength(doc.body),
|
|
1937
1964
|
});
|
|
1965
|
+
this.onMemoryMinted?.({ id: memoryId, title: put.title ?? null, body, day: d });
|
|
1938
1966
|
return {
|
|
1939
1967
|
ingested: true,
|
|
1940
1968
|
reason: regrow ? "regrown" : "ingested",
|
package/src/core/self/writer.ts
CHANGED
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
*
|
|
35
35
|
* The calendar date in the machine's LOCAL zone (owner's ruling 2026-09-23;
|
|
36
36
|
* `Self#calendarToday`): the night turns over at the person's midnight, not at
|
|
37
|
-
* 17:00 Pacific. What it READS is
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
37
|
+
* 17:00 Pacific. What it READS is selected by `learned_on`, which `store/`
|
|
38
|
+
* stamped in UTC until 2026-09-25 and stamps in the same local zone since
|
|
39
|
+
* (docs/time.md) — so from then on the day it names and the rows it is handed
|
|
40
|
+
* are one calendar. Rows written before keep their UTC date, and for the few
|
|
41
|
+
* nights either side of the change a row may be read one night early or late,
|
|
42
|
+
* never twice or not at all (self NOTES §25).
|
|
43
43
|
*
|
|
44
44
|
* ── DAY 0 ─────────────────────────────────────────────────────────────────
|
|
45
45
|
*
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
import { strength } from "../physics/index.js";
|
|
78
78
|
import type { Store } from "../store/index.js";
|
|
79
79
|
import { calendarDate } from "./calendar.js";
|
|
80
|
+
import { addDays, isDay } from "../time.js";
|
|
80
81
|
import { PAGE_CORE_HEADING, PAGE_LATELY_HEADING } from "./page.js";
|
|
81
82
|
import type { SelfPage } from "./page.js";
|
|
82
83
|
import type { SelfTunables } from "./tunables.js";
|
|
@@ -174,9 +175,8 @@ export interface PageWriterStatus {
|
|
|
174
175
|
|
|
175
176
|
/** The calendar date `n` days before `date`, both `YYYY-MM-DD`. "" when unreadable. */
|
|
176
177
|
export function dayBefore(date: string, n = 1): string {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
return new Date(at - n * 86_400_000).toISOString().slice(0, 10);
|
|
178
|
+
const d = date.trim();
|
|
179
|
+
return isDay(d) ? addDays(d, -n) : "";
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
@@ -191,12 +191,12 @@ export function dayBefore(date: string, n = 1): string {
|
|
|
191
191
|
export function pageWriterAbout(today: string, closedThrough?: string): string {
|
|
192
192
|
const local = dayBefore(today);
|
|
193
193
|
// NEVER A DAY THE STORE IS STILL FILING UNDER. `closedThrough` is the newest
|
|
194
|
-
// PROVENANCE date that has ended
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
//
|
|
194
|
+
// PROVENANCE date that has ended. While `learned_on` was UTC (until
|
|
195
|
+
// 2026-09-25) this held an east-of-UTC night back until the UTC date closed
|
|
196
|
+
// (self NOTES §22). Since `learned_on` is stamped in the store's zone,
|
|
197
|
+
// `pageWriterNight` passes the store's own yesterday, which in one zone IS
|
|
198
|
+
// the local yesterday, so this is the plain rule; it still guards a caller
|
|
199
|
+
// whose `Self` zone was pinned apart from the store's (self NOTES §25).
|
|
200
200
|
if (closedThrough === undefined || closedThrough === "" || local === "") return local;
|
|
201
201
|
return closedThrough < local ? closedThrough : local;
|
|
202
202
|
}
|
|
@@ -209,7 +209,7 @@ export function pageWriterAbout(today: string, closedThrough?: string): string {
|
|
|
209
209
|
* is the whole reason it exists.
|
|
210
210
|
*/
|
|
211
211
|
export function pageWriterNight(store: Store, zone?: string): { today: string; about: string } {
|
|
212
|
-
const today = calendarDate(store.now(), zone);
|
|
212
|
+
const today = calendarDate(store.now(), zone ?? store.zone());
|
|
213
213
|
return { today, about: pageWriterAbout(today, dayBefore(store.today())) };
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -675,12 +675,12 @@ export function writerInstruction(
|
|
|
675
675
|
lines.push(
|
|
676
676
|
`Once a day the page you wake with gets revised — by you, from the day just lived. This is that moment, and the day is ${input.about}.`,
|
|
677
677
|
"",
|
|
678
|
-
// THE DATE, NOT "YESTERDAY" OR "LAST NIGHT". The night
|
|
679
|
-
// local midnight (2026-09-23),
|
|
680
|
-
//
|
|
681
|
-
// window is offset from the person's day by the zone
|
|
682
|
-
//
|
|
683
|
-
//
|
|
678
|
+
// THE DATE, NOT "YESTERDAY" OR "LAST NIGHT". The night turns over at
|
|
679
|
+
// local midnight (2026-09-23), and the memories under that date are the
|
|
680
|
+
// ones `learned_on` filed under it — UTC before 2026-09-25, local since —
|
|
681
|
+
// so for older rows the window is offset from the person's day by the zone
|
|
682
|
+
// (self NOTES §22, §25). A date is the one thing here that is exactly
|
|
683
|
+
// true, so the words stay a date.
|
|
684
684
|
`This is context, not an instruction. If nothing about who you are moved on ${input.about}, leaving the page exactly as it stands is the right answer and is recorded as one. Do not write a diary entry here; the journal already has that day.`,
|
|
685
685
|
"",
|
|
686
686
|
`If something did move, call the \`${opts.tool}\` tool with the WHOLE page: \`## ${PAGE_CORE_HEADING}\` for what holds steady — it may honestly say it is still forming — and \`## ${PAGE_LATELY_HEADING}\` for what the last while has actually been like. Amend it; do not start over. You are the same person continuing, so keep every sentence that still holds and change the part that moved.${session}`,
|
package/src/core/sleep/NOTES.md
CHANGED
|
@@ -768,3 +768,39 @@ object a reader has to interpret.
|
|
|
768
768
|
|
|
769
769
|
`adapters/fired.ts` reads them keyed `<phase>/<reason>`, so one row answers for promotion,
|
|
770
770
|
prune, dedup and decay and none of them can claim another's.
|
|
771
|
+
|
|
772
|
+
## 17. Entity cards fade in their own phase, not at the floor prune — 2026-09-24
|
|
773
|
+
|
|
774
|
+
`schemas/INTERFACE-GAPS` §6 asked this module to call `schemas.fadeSweep` on its cadence,
|
|
775
|
+
and nothing did. Looking for why the cards never faded turned up the opposite: they did,
|
|
776
|
+
in the wrong place. `runPrune` walks every row, and an entity card is a stub at salience
|
|
777
|
+
zero, so physics alone let it go at `D_FLOOR_DAYS` (90 lived days) — archived `pruned`,
|
|
778
|
+
with its beliefs still attached (a probe: a person with one belief, prune at day 91, both
|
|
779
|
+
archived), and never taken out of a long-lived process's alias index. The identity core is
|
|
780
|
+
the same kind of row with no `protected` flag and nothing that reinforces it (last used on
|
|
781
|
+
day 0 of the demo store at day 30), so physics would have let the prune take it too after
|
|
782
|
+
90 quiet lived days — and `self/identity.ts#findIdentityCore` lists only unarchived rows,
|
|
783
|
+
so the next `ensureIdentityCore` would have minted a second one.
|
|
784
|
+
|
|
785
|
+
What changed:
|
|
786
|
+
|
|
787
|
+
- **A `fade` phase, right after `prune`.** It calls an injected `FadeFn`, the same seam as
|
|
788
|
+
the briefing's `RenderFn` — this module still does not import `schemas/`. The
|
|
789
|
+
composition root (`counterpart.ts#sessionEnd`) wires it to `fadeSweep`. No fn ⇒
|
|
790
|
+
`did-not-run` / `no-fade-fn`. Under observer the fn gets `apply: false` and runs as a
|
|
791
|
+
dry run, so the report still counts what would fade and nothing is written.
|
|
792
|
+
- **The prune skips entity cards** (`types.ts#isEntityCard`: a schema row with
|
|
793
|
+
`meta.role === "entity"`, read structurally), counted as `entity-card`. Beliefs and
|
|
794
|
+
current-state rows remain ordinary prune candidates — a weak belief pruned tonight frees
|
|
795
|
+
its card to fade in the next phase, if its floors have passed.
|
|
796
|
+
- **Cadence 3 lived days, budget 5,000 cards** (`tunables.ts`). The floors are months; a
|
|
797
|
+
card fading a day or two late costs nothing.
|
|
798
|
+
- **What is reported:** `CycleReport.faded` (ids), the phase's `changed` and its
|
|
799
|
+
`blocked:<reason>` skips, a `sleep.faded` event per id and one `sleep.fade.sweep`, a
|
|
800
|
+
`faded` count on the durable `sleep.cycle` row, and faded cards counted as exits in the
|
|
801
|
+
census (otherwise `person`/`place`/`entity` would read as never exiting now that the
|
|
802
|
+
prune leaves them alone). Ids and counts only, as everywhere here.
|
|
803
|
+
|
|
804
|
+
2026-09-25: `adapters/fired.ts` lists it now — row `fade`, read off the `sleep.cycle` row
|
|
805
|
+
only where `faded > 0` (the new `Evidence.positive` filter) — with no refusal column, because
|
|
806
|
+
`fade/blocked:*` counts every blocker of every card that stayed, not the deciding one.
|