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
package/src/adapters/fired.ts
CHANGED
|
@@ -31,7 +31,11 @@
|
|
|
31
31
|
* GROUP BY, so the events are read once — ascending, as `eventLog` returns
|
|
32
32
|
* them — and grouped here. A read that hits its ceiling says so and reports
|
|
33
33
|
* its totals as a floor rather than as a number.
|
|
34
|
-
* 2. **Windows are CALENDAR days,
|
|
34
|
+
* 2. **Windows are CALENDAR days, in the person's zone** (UTC until
|
|
35
|
+
* 2026-09-25; docs/time.md moved every person's day to local, and this
|
|
36
|
+
* is a read-only view over moments, so it follows — `Store#zone`). A row
|
|
37
|
+
* that carries its own `date` (a hook's) is read as written; hooks stamp
|
|
38
|
+
* that local too since the same day. The lived clock is advanced by the
|
|
35
39
|
* worker and has run seven lived days across fifteen calendar ones on the
|
|
36
40
|
* owner's own store, so a lived-day window would silently drop rows. The
|
|
37
41
|
* `sinceDay` bound is used only to keep the SQL cheap; a lived day is never
|
|
@@ -49,7 +53,7 @@
|
|
|
49
53
|
* from, and it still reads only fields a writer already fills.
|
|
50
54
|
*/
|
|
51
55
|
import { TUNABLES as ENCODE } from "../core/encode/tunables.js";
|
|
52
|
-
import {
|
|
56
|
+
import { addDays, daysBetween as calendarDaysBetween, localDate } from "../core/time.js";
|
|
53
57
|
import type { EventRow, ReadOnlyStore } from "../core/store/index.js";
|
|
54
58
|
import type { DurableEventName } from "./dashboard/registries.js";
|
|
55
59
|
|
|
@@ -143,7 +147,27 @@ export type ProbeId =
|
|
|
143
147
|
| `versions:${string}`;
|
|
144
148
|
|
|
145
149
|
export type Evidence =
|
|
146
|
-
| {
|
|
150
|
+
| {
|
|
151
|
+
readonly kind: "event";
|
|
152
|
+
readonly names: readonly DurableEventName[];
|
|
153
|
+
/**
|
|
154
|
+
* A NUMERIC PAYLOAD FIELD THAT MUST BE ABOVE ZERO for a row to count
|
|
155
|
+
* (2026-09-25, the entity-card fade). Some mechanisms have no row of their
|
|
156
|
+
* own and ride a row that lands whether they did anything or not: the fade
|
|
157
|
+
* is a count on the nightly `sleep.cycle` row, and reading that row plain
|
|
158
|
+
* would grade every night as a fade. With this set, a row counts toward
|
|
159
|
+
* `total`, the two windows and `lastFired` only when `payload[positive]`
|
|
160
|
+
* is a number greater than zero — a `null` (a cycle that died before it
|
|
161
|
+
* could count, scar §2.4) is not a zero and is not a firing either.
|
|
162
|
+
*
|
|
163
|
+
* The unit is still ROWS, like every other line on this page: a night that
|
|
164
|
+
* faded three cards is one firing. And a filtered reading carries NO
|
|
165
|
+
* refusals of its own — the row's refusal reader answers for every phase
|
|
166
|
+
* on it, and none of that is this mechanism's to claim. A mechanism that
|
|
167
|
+
* wants a refusal column names one with `Mechanism.refusals`.
|
|
168
|
+
*/
|
|
169
|
+
readonly positive?: string;
|
|
170
|
+
}
|
|
147
171
|
/** `undated`: the one line to print when the probe yields a count and no date
|
|
148
172
|
* at all — a column with no history is blind however many rows it holds. */
|
|
149
173
|
| { readonly kind: "probe"; readonly probe: ProbeId; readonly undated?: string }
|
|
@@ -534,6 +558,31 @@ export const MECHANISMS: readonly Mechanism[] = [
|
|
|
534
558
|
since: "2026-09-20",
|
|
535
559
|
},
|
|
536
560
|
},
|
|
561
|
+
{
|
|
562
|
+
// The entity-card fade (#215, 2026-09-24): its own sleep phase right after
|
|
563
|
+
// the prune, which now leaves cards alone (sleep NOTES §17). Its per-card
|
|
564
|
+
// events — `schema.faded`, `sleep.faded` — are in-process ring events, and
|
|
565
|
+
// the card itself is archived `faded-by-decay` with no date, so the one
|
|
566
|
+
// DURABLE trace is the `faded` count on the cycle row. Read plain, that row
|
|
567
|
+
// would make every night a fade; `positive` takes only the nights that
|
|
568
|
+
// faded something.
|
|
569
|
+
//
|
|
570
|
+
// **NO REFUSAL COLUMN, deliberately.** The phase's `fade/blocked:<reason>`
|
|
571
|
+
// skips count EVERY blocker of every card that stayed — `blockedBy` lists
|
|
572
|
+
// all the reasons a card may not fade, not the one that decided it — so
|
|
573
|
+
// even the rule-like ones (`has-live-attached-elements`, `identity-core`)
|
|
574
|
+
// land on cards nowhere near qualifying: the self card is blocked by
|
|
575
|
+
// `identity-core` at every sweep. Declaring them would reproduce the
|
|
576
|
+
// `dwell-too-short ×240` false alarm the prune row above describes. What
|
|
577
|
+
// would fix it: a per-card DECIDING reason, recorded only for cards whose
|
|
578
|
+
// physics verdict (the months of quiet) had already passed.
|
|
579
|
+
id: "fade",
|
|
580
|
+
label:
|
|
581
|
+
"a card nobody has mentioned in months fades out of the vocabulary (gently: months of quiet, longer for people)",
|
|
582
|
+
module: "sleep/fade.ts, schemas/index.ts",
|
|
583
|
+
evidence: { kind: "event", names: ["sleep.cycle"], positive: "faded" },
|
|
584
|
+
since: "2026-09-24",
|
|
585
|
+
},
|
|
537
586
|
{
|
|
538
587
|
id: "revision",
|
|
539
588
|
label: "a belief took a credited challenge and was revised under the pressure",
|
|
@@ -928,11 +977,13 @@ export interface FiredOptions {
|
|
|
928
977
|
readonly probes?: boolean;
|
|
929
978
|
}
|
|
930
979
|
|
|
931
|
-
/** `YYYY-MM-DD`, `back` days before `today
|
|
980
|
+
/** `YYYY-MM-DD`, `back` days before `today` — label arithmetic (`time.ts`). */
|
|
932
981
|
export function daysBefore(today: string, back: number): string {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
982
|
+
try {
|
|
983
|
+
return addDays(today, -back);
|
|
984
|
+
} catch {
|
|
985
|
+
return today;
|
|
986
|
+
}
|
|
936
987
|
}
|
|
937
988
|
|
|
938
989
|
/** True when this mechanism's refusal channel is younger than the window the
|
|
@@ -943,12 +994,13 @@ function comparisonIsTooYoung(id: string, w: Window): boolean {
|
|
|
943
994
|
return since !== undefined && since > w.previousFrom;
|
|
944
995
|
}
|
|
945
996
|
|
|
946
|
-
/** Whole
|
|
997
|
+
/** Whole calendar days from `from` to `to`, 0 when either date does not parse. */
|
|
947
998
|
export function daysBetween(from: string, to: string): number {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
999
|
+
try {
|
|
1000
|
+
return calendarDaysBetween(from, to);
|
|
1001
|
+
} catch {
|
|
1002
|
+
return 0;
|
|
1003
|
+
}
|
|
952
1004
|
}
|
|
953
1005
|
|
|
954
1006
|
/** The lived clock, or 0. A diagnostic may not become the thing that throws. */
|
|
@@ -970,6 +1022,7 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
|
|
|
970
1022
|
to: today,
|
|
971
1023
|
previousFrom: daysBefore(today, FIRED_DAYS * 2 - 1),
|
|
972
1024
|
previousTo: daysBefore(today, FIRED_DAYS),
|
|
1025
|
+
zone: store.zone(),
|
|
973
1026
|
};
|
|
974
1027
|
const log = readLog(store, window);
|
|
975
1028
|
const probed = opts.probes === false ? null : readProbes(store, window);
|
|
@@ -1052,6 +1105,8 @@ interface Window {
|
|
|
1052
1105
|
readonly to: string;
|
|
1053
1106
|
readonly previousFrom: string;
|
|
1054
1107
|
readonly previousTo: string;
|
|
1108
|
+
/** The zone a moment's calendar date is read in (`Store#zone`). */
|
|
1109
|
+
readonly zone: string;
|
|
1055
1110
|
}
|
|
1056
1111
|
|
|
1057
1112
|
/** A reading of one piece of evidence, before the state is decided. */
|
|
@@ -1153,7 +1208,7 @@ function readEvidence(m: Mechanism, log: LogRead, probed: Probed | null): Readin
|
|
|
1153
1208
|
? { ...EMPTY_READING, evidence: "no durable row", blind: m.evidence.reason }
|
|
1154
1209
|
: m.evidence.kind === "probe"
|
|
1155
1210
|
? probeReading(m.evidence.probe, m.evidence.undated ?? null, probed)
|
|
1156
|
-
: eventReading(m.evidence.names, log);
|
|
1211
|
+
: eventReading(m.evidence.names, log, m.evidence.positive);
|
|
1157
1212
|
if (m.refusals === undefined) return base;
|
|
1158
1213
|
// Refusals from ANOTHER row, folded in without touching the counts that say
|
|
1159
1214
|
// whether this mechanism fired.
|
|
@@ -1193,7 +1248,11 @@ function refusalReading(src: RefusalSource, log: LogRead): { refused: number; re
|
|
|
1193
1248
|
return { refused, refusals };
|
|
1194
1249
|
}
|
|
1195
1250
|
|
|
1196
|
-
function eventReading(
|
|
1251
|
+
function eventReading(
|
|
1252
|
+
names: readonly DurableEventName[],
|
|
1253
|
+
log: LogRead,
|
|
1254
|
+
positive?: string,
|
|
1255
|
+
): Reading {
|
|
1197
1256
|
let total = 0;
|
|
1198
1257
|
let inWindow = 0;
|
|
1199
1258
|
let inPreviousWindow = 0;
|
|
@@ -1201,7 +1260,7 @@ function eventReading(names: readonly DurableEventName[], log: LogRead): Reading
|
|
|
1201
1260
|
let lastFired: string | null = null;
|
|
1202
1261
|
const refusals = new Map<string, number>();
|
|
1203
1262
|
for (const name of names) {
|
|
1204
|
-
const t = log.byName.get(name);
|
|
1263
|
+
const t = log.byName.get(positive === undefined ? name : filteredKey(name, positive));
|
|
1205
1264
|
if (t === undefined) continue;
|
|
1206
1265
|
total += t.total;
|
|
1207
1266
|
inWindow += t.inWindow;
|
|
@@ -1221,7 +1280,9 @@ function eventReading(names: readonly DurableEventName[], log: LogRead): Reading
|
|
|
1221
1280
|
refused,
|
|
1222
1281
|
topRefusal: topOf(refusals),
|
|
1223
1282
|
refusals,
|
|
1224
|
-
evidence:
|
|
1283
|
+
// The filter is part of the evidence: `sleep.cycle` alone would read as the
|
|
1284
|
+
// same row the `sleep-cycle` line is, to the reader who greps.
|
|
1285
|
+
evidence: positive === undefined ? names.join(", ") : `${names.join(", ")} (${positive} > 0)`,
|
|
1225
1286
|
refusalEvidence: names.join(", "),
|
|
1226
1287
|
blind: null,
|
|
1227
1288
|
};
|
|
@@ -1256,6 +1317,32 @@ interface LogRead {
|
|
|
1256
1317
|
readonly oldestDate: string | null;
|
|
1257
1318
|
}
|
|
1258
1319
|
|
|
1320
|
+
/**
|
|
1321
|
+
* The tally key for a name read through a `positive` filter. A character no
|
|
1322
|
+
* durable event name carries, so it cannot collide with a real one.
|
|
1323
|
+
*/
|
|
1324
|
+
function filteredKey(name: string, field: string): string {
|
|
1325
|
+
return `${name}#${field}`;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* Every payload filter the registry declares, by event name — derived from
|
|
1330
|
+
* `MECHANISMS` rather than listed, so a row that adds a filter is tallied
|
|
1331
|
+
* without a second list to keep in step.
|
|
1332
|
+
*/
|
|
1333
|
+
const POSITIVE_FIELDS: ReadonlyMap<string, readonly string[]> = (() => {
|
|
1334
|
+
const out = new Map<string, string[]>();
|
|
1335
|
+
for (const m of MECHANISMS) {
|
|
1336
|
+
if (m.evidence.kind !== "event" || m.evidence.positive === undefined) continue;
|
|
1337
|
+
for (const name of m.evidence.names) {
|
|
1338
|
+
const fields = out.get(name) ?? [];
|
|
1339
|
+
if (!fields.includes(m.evidence.positive)) fields.push(m.evidence.positive);
|
|
1340
|
+
out.set(name, fields);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
return out;
|
|
1344
|
+
})();
|
|
1345
|
+
|
|
1259
1346
|
function emptyTally(): NameTally {
|
|
1260
1347
|
return {
|
|
1261
1348
|
total: 0,
|
|
@@ -1305,19 +1392,19 @@ function tallyRow(
|
|
|
1305
1392
|
w: Window,
|
|
1306
1393
|
age: { oldest: string | null },
|
|
1307
1394
|
): void {
|
|
1308
|
-
let t = byName.get(row.name);
|
|
1309
|
-
if (t === undefined) {
|
|
1310
|
-
t = emptyTally();
|
|
1311
|
-
byName.set(row.name, t);
|
|
1312
|
-
}
|
|
1313
|
-
t.total += 1;
|
|
1314
1395
|
const payload = payloadOf(row);
|
|
1315
|
-
const date = rowDate(row, payload);
|
|
1396
|
+
const date = rowDate(row, payload, w.zone);
|
|
1316
1397
|
if (age.oldest === null || date < age.oldest) age.oldest = date;
|
|
1317
|
-
|
|
1398
|
+
const t = countInto(byName, row.name, date, w);
|
|
1399
|
+
// THE FILTERED TALLIES, in the same pass (`Evidence.positive`). They count
|
|
1400
|
+
// the row and NOTHING ELSE: the refusal reader below answers for every phase
|
|
1401
|
+
// on a cycle row, and a filtered tally that copied it would hand the fade
|
|
1402
|
+
// row `prune/blocked:dwell-too-short ×240` on its own line.
|
|
1403
|
+
for (const field of POSITIVE_FIELDS.get(row.name) ?? []) {
|
|
1404
|
+
const v = payload[field];
|
|
1405
|
+
if (typeof v === "number" && v > 0) countInto(byName, filteredKey(row.name, field), date, w);
|
|
1406
|
+
}
|
|
1318
1407
|
const inWindow = date >= w.from && date <= w.to;
|
|
1319
|
-
if (inWindow) t.inWindow += 1;
|
|
1320
|
-
else if (date >= w.previousFrom && date <= w.previousTo) t.inPreviousWindow += 1;
|
|
1321
1408
|
if (!inWindow) return;
|
|
1322
1409
|
const reader = REFUSAL_READERS[row.name];
|
|
1323
1410
|
if (reader === undefined) return;
|
|
@@ -1328,12 +1415,31 @@ function tallyRow(
|
|
|
1328
1415
|
}
|
|
1329
1416
|
}
|
|
1330
1417
|
|
|
1418
|
+
/** One row counted under `key`: its total, its date, and which window it fell in. */
|
|
1419
|
+
function countInto(
|
|
1420
|
+
byName: Map<string, NameTally>,
|
|
1421
|
+
key: string,
|
|
1422
|
+
date: string,
|
|
1423
|
+
w: Window,
|
|
1424
|
+
): NameTally {
|
|
1425
|
+
let t = byName.get(key);
|
|
1426
|
+
if (t === undefined) {
|
|
1427
|
+
t = emptyTally();
|
|
1428
|
+
byName.set(key, t);
|
|
1429
|
+
}
|
|
1430
|
+
t.total += 1;
|
|
1431
|
+
if (t.lastDate === null || date > t.lastDate) t.lastDate = date;
|
|
1432
|
+
if (date >= w.from && date <= w.to) t.inWindow += 1;
|
|
1433
|
+
else if (date >= w.previousFrom && date <= w.previousTo) t.inPreviousWindow += 1;
|
|
1434
|
+
return t;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1331
1437
|
/** The CALENDAR date a row is about: its own field, else the wall clock it was
|
|
1332
1438
|
* written at. `day` is the lived-day column and answers a different question. */
|
|
1333
|
-
function rowDate(row: EventRow, payload: Record<string, unknown
|
|
1439
|
+
function rowDate(row: EventRow, payload: Record<string, unknown>, zone: string): string {
|
|
1334
1440
|
const date = payload["date"];
|
|
1335
1441
|
if (typeof date === "string" && date.length === 10) return date;
|
|
1336
|
-
return
|
|
1442
|
+
return localDate(row.at, zone);
|
|
1337
1443
|
}
|
|
1338
1444
|
|
|
1339
1445
|
function payloadOf(row: EventRow): Record<string, unknown> {
|
|
@@ -1491,6 +1597,7 @@ interface Probed {
|
|
|
1491
1597
|
readonly byId: ReadonlyMap<string, ProbeTally>;
|
|
1492
1598
|
readonly livedDay: number;
|
|
1493
1599
|
readonly truncated: boolean;
|
|
1600
|
+
readonly zone: string;
|
|
1494
1601
|
}
|
|
1495
1602
|
|
|
1496
1603
|
/**
|
|
@@ -1522,7 +1629,7 @@ function readProbes(store: ReadOnlyStore, w: Window): Probed {
|
|
|
1522
1629
|
// the row prints `lived day N` rather than a date so the reader can see
|
|
1523
1630
|
// which clock answered.
|
|
1524
1631
|
if (when !== null) {
|
|
1525
|
-
const date =
|
|
1632
|
+
const date = localDate(when, w.zone);
|
|
1526
1633
|
if (date >= w.from && date <= w.to) t.inWindow += 1;
|
|
1527
1634
|
else if (date >= w.previousFrom && date <= w.previousTo) t.inPreviousWindow += 1;
|
|
1528
1635
|
return;
|
|
@@ -1549,7 +1656,7 @@ function readProbes(store: ReadOnlyStore, w: Window): Probed {
|
|
|
1549
1656
|
bump(`versions:${v.reason}`, { livedDay: v.version_day, at: v.archived_at });
|
|
1550
1657
|
}
|
|
1551
1658
|
}
|
|
1552
|
-
return { byId, livedDay, truncated: scanned.length < ids.length };
|
|
1659
|
+
return { byId, livedDay, truncated: scanned.length < ids.length, zone: w.zone };
|
|
1553
1660
|
}
|
|
1554
1661
|
|
|
1555
1662
|
function probeReading(probe: ProbeId, undated: string | null, probed: Probed | null): Reading {
|
|
@@ -1568,7 +1675,7 @@ function probeReading(probe: ProbeId, undated: string | null, probed: Probed | n
|
|
|
1568
1675
|
inPreviousWindow: t.inPreviousWindow,
|
|
1569
1676
|
};
|
|
1570
1677
|
if (t.lastAt !== null) {
|
|
1571
|
-
return { ...counted, lastFired:
|
|
1678
|
+
return { ...counted, lastFired: localDate(t.lastAt, probed.zone), lastFiredIsDate: true };
|
|
1572
1679
|
}
|
|
1573
1680
|
if (t.lastLivedDay !== null) {
|
|
1574
1681
|
return {
|
|
@@ -299,7 +299,10 @@ JSON" was narrowed to what stays true: never without a notice, and never the doc
|
|
|
299
299
|
|
|
300
300
|
**Also filed from this build, for the modules that own them.**
|
|
301
301
|
|
|
302
|
-
-
|
|
302
|
+
- **Closed 2026-09-24** — `store/cache.ts#openCache` now leaves a cache from a newer build
|
|
303
|
+
as found (`cacheAhead`, #190).
|
|
304
|
+
|
|
305
|
+
**`store/cache.ts#openCache` stamps an AHEAD cache backwards.** It re-runs the DDL and
|
|
303
306
|
rewrites `cache_meta.schemaVersion` whenever the stamp DIFFERS, so a build opening a cache
|
|
304
307
|
a newer build wrote writes the older number over it instead of refusing, the way
|
|
305
308
|
`operational.ts` refuses `SCHEMA_AHEAD`. Not this server's hole (it never reopens) — a
|
|
@@ -619,3 +619,46 @@ anything else: `sqlite3 "$DB" "UPDATE meta SET value = '$V' WHERE key = 'schemaV
|
|
|
619
619
|
embedder is the local table, so `questionEmbedder` reads the configuration and opens the
|
|
620
620
|
table (or nothing, when the configuration switches it off). The notes above about "whose
|
|
621
621
|
keys" a configuration answers are history — it now answers "whose embedder knob".
|
|
622
|
+
|
|
623
|
+
## 2026-09-25 — every row a tool writes names its model (schema v7)
|
|
624
|
+
|
|
625
|
+
`sessionModel()` reads the bound session's registry record — the relay `chapter` has used
|
|
626
|
+
since #217 — and `note`, each `session_end` entry (the write-up door's included),
|
|
627
|
+
`chapter` and `self_page` pass it down to the row's `model` column. Unbound (a `note`
|
|
628
|
+
before any tool named a session) it is undefined and the row records NULL. The schema gate
|
|
629
|
+
is unchanged and was checked against the 0.3.1 build on a store this build migrated: the
|
|
630
|
+
old server refuses every tool `schema-ahead` ("Run /mcp and Reconnect"). `status`'s
|
|
631
|
+
removal dates are the person's day (`localDate(at, store.zone())`), no longer UTC.
|
|
632
|
+
|
|
633
|
+
## 2026-09-25 — feelings on `note` and `session_end` (schema v7)
|
|
634
|
+
|
|
635
|
+
`feelings: [{ whose, core, emotion, strength, carried_by?, beneath? }]` on a `note` or a
|
|
636
|
+
`session_end` entry (`beneath` is another item's index). `readFeelings` reads and runs
|
|
637
|
+
the store's pure `checkFeelings` BEFORE the deposit, so a bad list refuses its note or
|
|
638
|
+
its one entry (`feelings-malformed`, naming the item and reason; siblings still run) and
|
|
639
|
+
no memory lands with its feelings dropped. After a mint, `recordFeelings` writes them
|
|
640
|
+
with the session's model and answers `feelings: { stored, other? }`; each `other` item
|
|
641
|
+
carries the nearest wheel keys and a one-line note to rewrite with. A throw there costs
|
|
642
|
+
the feelings, never the memory, and says so. No salience, decay or recall change.
|
|
643
|
+
|
|
644
|
+
### Review of #231 (2026-09-25)
|
|
645
|
+
|
|
646
|
+
- **`note` before a bind records NULL for `model`, and that is accepted (N3).** On the
|
|
647
|
+
live host the server is launched with no `--session`, so `sessionModel()` has nothing
|
|
648
|
+
to read until a `chapter` or `session_end` binds it. Other effects of the bind:
|
|
649
|
+
- After `/model`, the first write is credited to the previous model; the record is
|
|
650
|
+
refreshed at the next boundary.
|
|
651
|
+
- A write is never credited to another session's model, because the bind is frozen for
|
|
652
|
+
the life of the process.
|
|
653
|
+
- **S2 and S3.** `readFeelings` now works as follows:
|
|
654
|
+
- It checks `whose`, `core`, `emotion`, `carried_by` and `other_word` are strings before
|
|
655
|
+
anything else runs.
|
|
656
|
+
- `checkFeelings` refuses an over-long `emotion` or `other_word` before any
|
|
657
|
+
edit-distance scoring.
|
|
658
|
+
- Any throw in the reader becomes that entry's `feelings-malformed`, so the siblings in
|
|
659
|
+
a `session_end` still land.
|
|
660
|
+
- At the door, `beneath` must be an integer index, so an id can no longer pass the door
|
|
661
|
+
and fail only after the memory has minted.
|
|
662
|
+
- `other_word` is now in the published schema, so the schema and the reader agree.
|
|
663
|
+
- **N6.** A note that did not land (a duplicate, a gate) answers
|
|
664
|
+
`feelings: { stored: 0, reason: "memory-not-stored" }`.
|
|
@@ -169,6 +169,10 @@ export function launchOptions(
|
|
|
169
169
|
export function questionEmbedder(path = CONFIG_PATH): {
|
|
170
170
|
embedder: LiveEmbedder | null;
|
|
171
171
|
reason: string;
|
|
172
|
+
/** The configuration's `snapshots.dir`, for the store's pre-migration copy. */
|
|
173
|
+
snapshotsDir?: string;
|
|
174
|
+
/** The configuration's `timeZone` (docs/time.md), when it names a real zone. */
|
|
175
|
+
timeZone?: string;
|
|
172
176
|
} {
|
|
173
177
|
let raw: unknown;
|
|
174
178
|
try {
|
|
@@ -184,6 +188,8 @@ export function questionEmbedder(path = CONFIG_PATH): {
|
|
|
184
188
|
const config = withEmbedderDefault(load.config);
|
|
185
189
|
return {
|
|
186
190
|
reason: load.reason,
|
|
191
|
+
...(config.snapshots?.dir === undefined ? {} : { snapshotsDir: config.snapshots.dir }),
|
|
192
|
+
...(config.timeZone === undefined ? {} : { timeZone: config.timeZone }),
|
|
187
193
|
// `openEmbedder` is the ONE answer to "is there an embedder": the knob is
|
|
188
194
|
// the gate and an observer gets none.
|
|
189
195
|
embedder: openEmbedder(config),
|
|
@@ -228,7 +234,7 @@ async function main(): Promise<void> {
|
|
|
228
234
|
process.exitCode = 1;
|
|
229
235
|
return;
|
|
230
236
|
}
|
|
231
|
-
const { embedder, reason } = questionEmbedder(choice.path);
|
|
237
|
+
const { embedder, reason, snapshotsDir, timeZone } = questionEmbedder(choice.path);
|
|
232
238
|
const unreadable = namedUnreadableRefusal(choice, reason);
|
|
233
239
|
if (unreadable !== null) {
|
|
234
240
|
process.stderr.write(`${unreadable}\n`);
|
|
@@ -290,6 +296,8 @@ async function main(): Promise<void> {
|
|
|
290
296
|
observer: stance === "observer" || opts.observer,
|
|
291
297
|
scopesFile,
|
|
292
298
|
embedder,
|
|
299
|
+
...(snapshotsDir === undefined ? {} : { snapshotsDir }),
|
|
300
|
+
...(timeZone === undefined ? {} : { timeZone }),
|
|
293
301
|
});
|
|
294
302
|
// THE BUILD THIS PROCESS WILL KEEP FOR THE REST OF THE SESSION, left where
|
|
295
303
|
// the hooks can compare it with the installed one every turn
|
|
@@ -86,6 +86,11 @@ export interface OpenServerOptions extends Omit<McpServerOptions, "counterpart">
|
|
|
86
86
|
* paid seat's sync face is a cache, so passing it costs no call.
|
|
87
87
|
*/
|
|
88
88
|
embed?: Embedder;
|
|
89
|
+
/** Where the store's pre-migration copy goes — the host config's
|
|
90
|
+
* `snapshots.dir`, so it lands where rotation and doctor look. */
|
|
91
|
+
snapshotsDir?: string;
|
|
92
|
+
/** The host config's `timeZone` (docs/time.md); absent, the machine's zone. */
|
|
93
|
+
timeZone?: string;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
/** The sync face of a live embedder, when `embedder` is one. Duck-typed on purpose: this file must not import the claude-code adapter. */
|
|
@@ -104,6 +109,8 @@ export function openServer(opts: OpenServerOptions = {}): McpServer {
|
|
|
104
109
|
const counterpart = Counterpart.open({
|
|
105
110
|
...(embed === undefined ? {} : { embed }),
|
|
106
111
|
...(opts.dir === undefined ? {} : { dir: opts.dir }),
|
|
112
|
+
...(opts.snapshotsDir === undefined ? {} : { snapshotsDir: opts.snapshotsDir }),
|
|
113
|
+
...(opts.timeZone === undefined ? {} : { timeZone: opts.timeZone }),
|
|
107
114
|
...(opts.observer === undefined ? {} : { observer: opts.observer }),
|
|
108
115
|
...(opts.owner === undefined ? {} : { owner: opts.owner }),
|
|
109
116
|
});
|