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
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/api/memories` — the constellation and the kinds; `/api/memories/list` — every memory.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `web/views.ts`, which re-exports every public name from here;
|
|
5
|
+
* the four rules in that file's header apply to every line below.
|
|
6
|
+
*/
|
|
7
|
+
import { TUNABLES as PHYSICS, band as bandOf, strength as strengthOf } from "../../../../core/physics/index.js";
|
|
8
|
+
import { isJournal } from "../../../../core/sleep/index.js";
|
|
9
|
+
import { rowToPhysics } from "../../../../core/store/index.js";
|
|
10
|
+
import type { Band, Kind } from "../../../../core/types.js";
|
|
11
|
+
import { NEVER, NONE } from "../../layout.js";
|
|
12
|
+
import { BANDS, KINDS } from "../../registries.js";
|
|
13
|
+
import type { DashboardSource } from "../../source.js";
|
|
14
|
+
import { WITHHELD, revealHere } from "../reveal.js";
|
|
15
|
+
import { archiveWords } from "./archive-words.js";
|
|
16
|
+
import { BAND_GLOSS } from "./rows.js";
|
|
17
|
+
import type { BarRow } from "./rows.js";
|
|
18
|
+
import { absenceFor, census, countMap } from "./shared.js";
|
|
19
|
+
import type { MemoryLine } from "./shared.js";
|
|
20
|
+
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
// memories
|
|
23
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
export interface KindRow {
|
|
26
|
+
readonly kind: Kind;
|
|
27
|
+
readonly count: number;
|
|
28
|
+
readonly meanStrength: number;
|
|
29
|
+
readonly absent: string | null;
|
|
30
|
+
readonly wSal: number;
|
|
31
|
+
readonly wRep: number;
|
|
32
|
+
readonly kappa: number;
|
|
33
|
+
readonly iota: number;
|
|
34
|
+
readonly gloss: string;
|
|
35
|
+
/** The kind in words, for a reader who will never see κ or ι: what it is,
|
|
36
|
+
* how fast it fades, how easily it is corrected. */
|
|
37
|
+
readonly plain: { readonly label: string; readonly what: string; readonly fades: string; readonly corrects: string };
|
|
38
|
+
/** Where this kind's κ sits between the slowest- and fastest-fading kinds,
|
|
39
|
+
* 0.2 (slowest) to 1 (fastest). For a small five-step bar. */
|
|
40
|
+
readonly fadeSpeed: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface MemoriesView {
|
|
44
|
+
readonly day: number;
|
|
45
|
+
readonly total: number;
|
|
46
|
+
/** Of `total`: memories proper — the number `counterparts status` prints. */
|
|
47
|
+
readonly memories: number;
|
|
48
|
+
/** Of `total`: entities and beliefs about them (schema rows). */
|
|
49
|
+
readonly schemas: number;
|
|
50
|
+
readonly points: MemoryLine[];
|
|
51
|
+
readonly distribution: { from: number; to: number; count: number }[];
|
|
52
|
+
/** Strength in ten steps, each step split by today's band — the scatter's
|
|
53
|
+
* right margin. Over every row, not only the plotted ones. */
|
|
54
|
+
readonly strengthByBand: { from: number; to: number; bands: Record<string, number> }[];
|
|
55
|
+
readonly bands: BarRow[];
|
|
56
|
+
readonly kinds: KindRow[];
|
|
57
|
+
readonly pointsAbsent: string | null;
|
|
58
|
+
readonly note: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const KIND_GLOSS: Record<Kind, string> = {
|
|
62
|
+
self: "who I am — salience only, and the slowest to be argued out of",
|
|
63
|
+
person: "someone I know — salience carries it, repetition does not",
|
|
64
|
+
entity: "a thing in the world — both arms count",
|
|
65
|
+
skill: "how to do something — repetition is nearly all of it, and it erodes slowest",
|
|
66
|
+
place: "somewhere — repetition-driven, slow to erode",
|
|
67
|
+
fact: "a plain fact — erodes fastest, and the cheapest to overturn",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Each kind, in plain words (owner, 2026-09-25: "the kinds table in words").
|
|
71
|
+
* The words are the κ/ι ordering said aloud; the numbers stay in the JSON. */
|
|
72
|
+
const KIND_PLAIN: Record<Kind, KindRow["plain"]> = {
|
|
73
|
+
self: { label: "About me", what: "who I am", fades: "fade slowly", corrects: "hardest to argue out of" },
|
|
74
|
+
person: { label: "People", what: "someone I know", fades: "fade slowly", corrects: "hard to correct" },
|
|
75
|
+
entity: { label: "Things", what: "a thing in the world", fades: "fade fairly fast", corrects: "take some arguing to correct" },
|
|
76
|
+
skill: { label: "Skills", what: "how to do something", fades: "fade slowest", corrects: "easy to correct" },
|
|
77
|
+
place: { label: "Places", what: "somewhere", fades: "fade fairly fast", corrects: "easy to correct" },
|
|
78
|
+
fact: { label: "Facts", what: "a plain fact", fades: "fade fastest", corrects: "easiest to correct" },
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function fadeSpeed(kappa: number): number {
|
|
82
|
+
const all = KINDS.map((k) => PHYSICS.KINDS[k].kappa);
|
|
83
|
+
const lo = Math.min(...all);
|
|
84
|
+
const hi = Math.max(...all);
|
|
85
|
+
return hi === lo ? 1 : 0.2 + 0.8 * ((kappa - lo) / (hi - lo));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function memoriesView(src: DashboardSource, opts: { limit?: number } = {}): MemoriesView {
|
|
89
|
+
const store = src.store;
|
|
90
|
+
const day = store.livedDay();
|
|
91
|
+
const rows = census(src);
|
|
92
|
+
const limit = opts.limit ?? 4000;
|
|
93
|
+
const byKind = countMap<Kind>(rows, "kind");
|
|
94
|
+
const byBand = countMap<Band>(rows, "band");
|
|
95
|
+
const peak = Math.max(1, ...BANDS.map((b) => byBand.get(b) ?? 0));
|
|
96
|
+
const everLived = day > 0 || rows.length > 0;
|
|
97
|
+
|
|
98
|
+
const meanByKind = new Map<Kind, number[]>();
|
|
99
|
+
for (const r of rows) {
|
|
100
|
+
const list = meanByKind.get(r.kind) ?? [];
|
|
101
|
+
list.push(r.strength);
|
|
102
|
+
meanByKind.set(r.kind, list);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const buckets = 20;
|
|
106
|
+
const distribution = Array.from({ length: buckets }, (_, i) => ({
|
|
107
|
+
from: i / buckets,
|
|
108
|
+
to: (i + 1) / buckets,
|
|
109
|
+
count: 0,
|
|
110
|
+
}));
|
|
111
|
+
for (const r of rows) {
|
|
112
|
+
const i = Math.min(buckets - 1, Math.max(0, Math.floor(r.strength * buckets)));
|
|
113
|
+
const bucket = distribution[i];
|
|
114
|
+
if (bucket !== undefined) bucket.count += 1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const steps = 10;
|
|
118
|
+
const strengthByBand = Array.from({ length: steps }, (_, i) => ({
|
|
119
|
+
from: i / steps,
|
|
120
|
+
to: (i + 1) / steps,
|
|
121
|
+
bands: Object.fromEntries(BANDS.map((b) => [b, 0])) as Record<string, number>,
|
|
122
|
+
}));
|
|
123
|
+
for (const r of rows) {
|
|
124
|
+
const step = strengthByBand[Math.min(steps - 1, Math.max(0, Math.floor(r.strength * steps)))];
|
|
125
|
+
if (step !== undefined) step.bands[r.band] = (step.bands[r.band] ?? 0) + 1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
day,
|
|
130
|
+
total: rows.length,
|
|
131
|
+
memories: rows.filter((r) => !r.schema).length,
|
|
132
|
+
schemas: rows.filter((r) => r.schema).length,
|
|
133
|
+
strengthByBand,
|
|
134
|
+
points: rows.slice(0, limit),
|
|
135
|
+
pointsAbsent: rows.length === 0 ? (everLived ? NONE : NEVER) : null,
|
|
136
|
+
distribution,
|
|
137
|
+
bands: BANDS.map((b) => {
|
|
138
|
+
const count = byBand.get(b) ?? 0;
|
|
139
|
+
return { label: b, count, fraction: count / peak, note: BAND_GLOSS[b], absent: absenceFor(count, everLived) };
|
|
140
|
+
}),
|
|
141
|
+
kinds: KINDS.map((kind) => {
|
|
142
|
+
const count = byKind.get(kind) ?? 0;
|
|
143
|
+
const list = meanByKind.get(kind) ?? [];
|
|
144
|
+
const tunables = PHYSICS.KINDS[kind];
|
|
145
|
+
return {
|
|
146
|
+
kind,
|
|
147
|
+
count,
|
|
148
|
+
meanStrength: list.length === 0 ? 0 : list.reduce((a, b) => a + b, 0) / list.length,
|
|
149
|
+
absent: absenceFor(count, everLived),
|
|
150
|
+
wSal: tunables.wSal,
|
|
151
|
+
wRep: tunables.wRep,
|
|
152
|
+
kappa: tunables.kappa,
|
|
153
|
+
iota: tunables.iota,
|
|
154
|
+
gloss: KIND_GLOSS[kind],
|
|
155
|
+
plain: KIND_PLAIN[kind] ?? { label: kind, what: KIND_GLOSS[kind] ?? kind, fades: "", corrects: "" },
|
|
156
|
+
fadeSpeed: fadeSpeed(tunables.kappa),
|
|
157
|
+
};
|
|
158
|
+
}),
|
|
159
|
+
note: "Every dot is one memory — or one of the beliefs and entities the schemas hold, which decay and consolidate the same way and are counted apart only where a headline says memories. How many lived days old across, how strong up, how much it mattered at encoding as its size. Colour is the band it is in today, computed now — not the band it was born into.",
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
164
|
+
// the list — every memory, with its words, a page at a time
|
|
165
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
export type ListState = "live" | "archived" | "all";
|
|
168
|
+
|
|
169
|
+
export interface ListRow {
|
|
170
|
+
readonly id: string;
|
|
171
|
+
/** The title, when the memory carries one (withheld when confidential). */
|
|
172
|
+
readonly title: string | null;
|
|
173
|
+
/** The first line of the memory's own words — or its named absence, or the withholding. */
|
|
174
|
+
readonly line: string;
|
|
175
|
+
readonly confidential: boolean;
|
|
176
|
+
readonly kind: Kind;
|
|
177
|
+
readonly band: Band;
|
|
178
|
+
readonly strength: number;
|
|
179
|
+
readonly bornDay: number;
|
|
180
|
+
/** Lived days since it was born. */
|
|
181
|
+
readonly livedDays: number;
|
|
182
|
+
/** Why it was archived, in plain words; null while it is live. */
|
|
183
|
+
readonly archived: string | null;
|
|
184
|
+
/** The reason exactly as the store recorded it. */
|
|
185
|
+
readonly archivedReason: string | null;
|
|
186
|
+
/** An entity or a belief about one (a schema row), not a memory proper. */
|
|
187
|
+
readonly schema: boolean;
|
|
188
|
+
/** For a schema row: what it is — "entity", "belief", "current state". */
|
|
189
|
+
readonly schemaRole: string | null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface MemoryListView {
|
|
193
|
+
readonly day: number;
|
|
194
|
+
readonly state: ListState;
|
|
195
|
+
readonly kind: Kind | null;
|
|
196
|
+
readonly band: Band | null;
|
|
197
|
+
readonly offset: number;
|
|
198
|
+
readonly limit: number;
|
|
199
|
+
/** Rows matching every filter — what the pager pages over. */
|
|
200
|
+
readonly total: number;
|
|
201
|
+
/** Within the live/archived choice alone, so every chip can say its count. */
|
|
202
|
+
readonly counts: {
|
|
203
|
+
readonly live: number;
|
|
204
|
+
readonly archived: number;
|
|
205
|
+
readonly kinds: Record<string, number>;
|
|
206
|
+
readonly bands: Record<string, number>;
|
|
207
|
+
};
|
|
208
|
+
readonly rows: ListRow[];
|
|
209
|
+
readonly absent: string | null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** The archive reasons the core writes, said the way a person would say them. */
|
|
213
|
+
export const LIST_MAX = 200;
|
|
214
|
+
|
|
215
|
+
/** A schema row's role, from its own meta: an entity has no `entityId` to hang on. */
|
|
216
|
+
function schemaRole(meta: string): string {
|
|
217
|
+
try {
|
|
218
|
+
const m = JSON.parse(meta) as Record<string, unknown>;
|
|
219
|
+
if (m["role"] === "current-state") return "current state";
|
|
220
|
+
if (typeof m["entityId"] === "string") return "belief";
|
|
221
|
+
return "entity";
|
|
222
|
+
} catch {
|
|
223
|
+
return "entity";
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function firstLine(body: string, width: number): string {
|
|
228
|
+
const line = body
|
|
229
|
+
.split("\n")
|
|
230
|
+
.map((l) => l.trim())
|
|
231
|
+
.find((l) => l.length > 0 && !l.startsWith("#"));
|
|
232
|
+
const t = line ?? body.trim();
|
|
233
|
+
return t.length > width ? `${t.slice(0, width - 1).trimEnd()}…` : t;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* `/api/memories/list` — every memory, newest first, filtered and paged HERE so
|
|
238
|
+
* a store of twenty thousand rows sends one page. The sort and the filters read
|
|
239
|
+
* only the row columns and the physics (one row read per id); the words are
|
|
240
|
+
* read for the page slice alone, through `revealHere` — an archived row's OWN
|
|
241
|
+
* words, never its successor's.
|
|
242
|
+
*/
|
|
243
|
+
export function memoryListView(
|
|
244
|
+
src: DashboardSource,
|
|
245
|
+
opts: { state?: string | null; kind?: string | null; band?: string | null; offset?: number; limit?: number } = {},
|
|
246
|
+
): MemoryListView {
|
|
247
|
+
const store = src.store;
|
|
248
|
+
const day = store.livedDay();
|
|
249
|
+
const state: ListState = opts.state === "archived" || opts.state === "all" ? opts.state : "live";
|
|
250
|
+
const kind = KINDS.includes(opts.kind as Kind) ? (opts.kind as Kind) : null;
|
|
251
|
+
const band = BANDS.includes(opts.band as Band) ? (opts.band as Band) : null;
|
|
252
|
+
const limit = Math.max(1, Math.min(LIST_MAX, Math.floor(opts.limit ?? 50)));
|
|
253
|
+
const offset = Math.max(0, Math.floor(opts.offset ?? 0));
|
|
254
|
+
|
|
255
|
+
interface Slim {
|
|
256
|
+
id: string;
|
|
257
|
+
kind: Kind;
|
|
258
|
+
band: Band;
|
|
259
|
+
strength: number;
|
|
260
|
+
bornDay: number;
|
|
261
|
+
learnedOn: string;
|
|
262
|
+
archived: boolean;
|
|
263
|
+
}
|
|
264
|
+
const all: Slim[] = [];
|
|
265
|
+
let live = 0;
|
|
266
|
+
let archived = 0;
|
|
267
|
+
for (const id of store.list({})) {
|
|
268
|
+
const row = store.row(id);
|
|
269
|
+
if (row === undefined || isJournal(row)) continue;
|
|
270
|
+
const isArchived = row.archived === 1;
|
|
271
|
+
if (isArchived) archived += 1;
|
|
272
|
+
else live += 1;
|
|
273
|
+
if (state === "live" && isArchived) continue;
|
|
274
|
+
if (state === "archived" && !isArchived) continue;
|
|
275
|
+
let b: Band = row.band;
|
|
276
|
+
let s = 0;
|
|
277
|
+
try {
|
|
278
|
+
const physics = rowToPhysics(row);
|
|
279
|
+
b = bandOf(physics, day);
|
|
280
|
+
s = strengthOf(physics, day);
|
|
281
|
+
} catch {
|
|
282
|
+
/* a row whose physics will not compute still lists, at zero */
|
|
283
|
+
}
|
|
284
|
+
all.push({ id, kind: row.kind, band: b, strength: s, bornDay: row.birth_day, learnedOn: row.learned_on, archived: isArchived });
|
|
285
|
+
}
|
|
286
|
+
const kinds: Record<string, number> = Object.fromEntries(KINDS.map((k) => [k, 0]));
|
|
287
|
+
const bands: Record<string, number> = Object.fromEntries(BANDS.map((b) => [b, 0]));
|
|
288
|
+
for (const r of all) {
|
|
289
|
+
kinds[r.kind] = (kinds[r.kind] ?? 0) + 1;
|
|
290
|
+
bands[r.band] = (bands[r.band] ?? 0) + 1;
|
|
291
|
+
}
|
|
292
|
+
const matching = all.filter((r) => (kind === null || r.kind === kind) && (band === null || r.band === band));
|
|
293
|
+
// Newest first: the lived day it was born, then the calendar day it was
|
|
294
|
+
// recorded, then the id — so the order is defined, not SQLite's.
|
|
295
|
+
matching.sort(
|
|
296
|
+
(a, b) =>
|
|
297
|
+
b.bornDay - a.bornDay ||
|
|
298
|
+
(a.learnedOn < b.learnedOn ? 1 : a.learnedOn > b.learnedOn ? -1 : 0) ||
|
|
299
|
+
(a.id < b.id ? -1 : a.id > b.id ? 1 : 0),
|
|
300
|
+
);
|
|
301
|
+
const rows: ListRow[] = matching.slice(offset, offset + limit).map((r) => {
|
|
302
|
+
const row = store.row(r.id);
|
|
303
|
+
const here = revealHere(store, r.id, 160);
|
|
304
|
+
let title: string | null = null;
|
|
305
|
+
let line: string;
|
|
306
|
+
if (!here.present) line = here.label;
|
|
307
|
+
else if (here.confidential) line = WITHHELD;
|
|
308
|
+
else {
|
|
309
|
+
const t = row?.title ?? null;
|
|
310
|
+
title = t !== null && t.trim().length > 0 ? t.trim() : null;
|
|
311
|
+
line = firstLine(row?.body ?? "", 160) || here.label;
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
id: r.id,
|
|
315
|
+
title,
|
|
316
|
+
line,
|
|
317
|
+
confidential: here.confidential,
|
|
318
|
+
kind: r.kind,
|
|
319
|
+
band: r.band,
|
|
320
|
+
strength: r.strength,
|
|
321
|
+
bornDay: r.bornDay,
|
|
322
|
+
livedDays: Math.max(0, day - r.bornDay),
|
|
323
|
+
archived: r.archived ? archiveWords(row?.archived_reason ?? null, (row?.superseded_by ?? null) !== null) : null,
|
|
324
|
+
archivedReason: r.archived ? (row?.archived_reason ?? null) : null,
|
|
325
|
+
schema: row?.type === "schema",
|
|
326
|
+
schemaRole: row?.type === "schema" ? schemaRole(row.meta) : null,
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
const everLived = day > 0 || live + archived > 0;
|
|
330
|
+
return {
|
|
331
|
+
day,
|
|
332
|
+
state,
|
|
333
|
+
kind,
|
|
334
|
+
band,
|
|
335
|
+
offset,
|
|
336
|
+
limit,
|
|
337
|
+
total: matching.length,
|
|
338
|
+
counts: { live, archived, kinds, bands },
|
|
339
|
+
rows,
|
|
340
|
+
absent: matching.length === 0 ? (everLived ? NONE : NEVER) : null,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/api/memory` — one memory, opened.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `web/views.ts`, which re-exports every public name from here;
|
|
5
|
+
* the four rules in that file's header apply to every line below.
|
|
6
|
+
*/
|
|
7
|
+
import { band, rep, sal, strength } from "../../../../core/physics/index.js";
|
|
8
|
+
import { isJournal } from "../../../../core/sleep/index.js";
|
|
9
|
+
import type { Band, Kind } from "../../../../core/types.js";
|
|
10
|
+
import type { DashboardSource } from "../../source.js";
|
|
11
|
+
import { WITHHELD, gistOfDoc, reveal } from "../reveal.js";
|
|
12
|
+
|
|
13
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
14
|
+
// one memory, opened
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
export interface MemoryDetail {
|
|
18
|
+
readonly found: boolean;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly headId: string | null;
|
|
21
|
+
readonly askedFor: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* True when this row is a JOURNAL entry rather than a memory. It matters on
|
|
24
|
+
* an inspection surface: an episode is the source a memory was made from, it
|
|
25
|
+
* sits outside every sleep phase, and the physics below it is recorded but
|
|
26
|
+
* never acted on. Printing its strength without saying that would invite the
|
|
27
|
+
* owner to read a number the engine ignores.
|
|
28
|
+
*/
|
|
29
|
+
readonly journal: boolean;
|
|
30
|
+
readonly title: string;
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly confidential: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Which record this is — the revision it is on, and the hash of the text
|
|
35
|
+
* above.
|
|
36
|
+
*
|
|
37
|
+
* This pair replaced the memory file's path in the modal's subtitle. The path
|
|
38
|
+
* named a filesystem layout, and a store is not its layout: what identifies a
|
|
39
|
+
* memory is its id, and what identifies THIS reading of it is the revision and
|
|
40
|
+
* the hash. The id the copy button hands over is `id`.
|
|
41
|
+
*
|
|
42
|
+
* `contentHash` is blank when the body is withheld — see below.
|
|
43
|
+
*/
|
|
44
|
+
readonly revision: number;
|
|
45
|
+
readonly contentHash: string;
|
|
46
|
+
readonly kind: Kind;
|
|
47
|
+
readonly band: Band;
|
|
48
|
+
readonly recordedBand: string;
|
|
49
|
+
readonly strength: number;
|
|
50
|
+
readonly salience: { relevance: number; emotional: number; predictive: number; novelty: number | null; claimed: number | null; combined: number };
|
|
51
|
+
readonly repetition: number;
|
|
52
|
+
readonly uses: number;
|
|
53
|
+
readonly reinforcedDays: number;
|
|
54
|
+
readonly bornDay: number;
|
|
55
|
+
readonly lastUsedDay: number;
|
|
56
|
+
readonly learnedOn: string;
|
|
57
|
+
readonly happenedOn: string | null;
|
|
58
|
+
readonly consolidated: boolean;
|
|
59
|
+
readonly promoted: boolean;
|
|
60
|
+
readonly protected: boolean;
|
|
61
|
+
readonly pressure: number;
|
|
62
|
+
readonly bar: number | null;
|
|
63
|
+
readonly archived: string | null;
|
|
64
|
+
readonly removal: { stage: string; actor: string; reason: string | null; at: number }[];
|
|
65
|
+
readonly edges: { id: string; text: string; weight: number; confidential: boolean }[];
|
|
66
|
+
readonly points: { role: string; id: string; text: string }[];
|
|
67
|
+
readonly versions: { seq: number; reason: string; day: number; became: string }[];
|
|
68
|
+
readonly prospective: { date: string; state: string; fires: number; precision: string }[];
|
|
69
|
+
readonly absence: string | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
|
|
73
|
+
const store = src.store;
|
|
74
|
+
const day = store.livedDay();
|
|
75
|
+
const r = reveal(store, id, 120);
|
|
76
|
+
const empty = {
|
|
77
|
+
found: false,
|
|
78
|
+
id,
|
|
79
|
+
headId: r.headId,
|
|
80
|
+
askedFor: null,
|
|
81
|
+
journal: false,
|
|
82
|
+
title: "",
|
|
83
|
+
text: "",
|
|
84
|
+
confidential: false,
|
|
85
|
+
revision: 0,
|
|
86
|
+
contentHash: "",
|
|
87
|
+
kind: "fact" as Kind,
|
|
88
|
+
band: "episodic" as Band,
|
|
89
|
+
recordedBand: "—",
|
|
90
|
+
strength: 0,
|
|
91
|
+
salience: { relevance: 0, emotional: 0, predictive: 0, novelty: null, claimed: null, combined: 0 },
|
|
92
|
+
repetition: 0,
|
|
93
|
+
uses: 0,
|
|
94
|
+
reinforcedDays: 0,
|
|
95
|
+
bornDay: 0,
|
|
96
|
+
lastUsedDay: 0,
|
|
97
|
+
learnedOn: "—",
|
|
98
|
+
happenedOn: null,
|
|
99
|
+
consolidated: false,
|
|
100
|
+
promoted: false,
|
|
101
|
+
protected: false,
|
|
102
|
+
pressure: 0,
|
|
103
|
+
bar: null,
|
|
104
|
+
archived: null,
|
|
105
|
+
removal: store.removalRecord(id).map((x) => ({ stage: x.stage, actor: x.actor, reason: x.reason, at: x.at })),
|
|
106
|
+
edges: [],
|
|
107
|
+
points: [],
|
|
108
|
+
versions: [],
|
|
109
|
+
prospective: [],
|
|
110
|
+
absence: r.label,
|
|
111
|
+
} satisfies MemoryDetail;
|
|
112
|
+
|
|
113
|
+
if (!r.present || r.headId === null) return empty;
|
|
114
|
+
const headId = r.headId;
|
|
115
|
+
let doc;
|
|
116
|
+
let row;
|
|
117
|
+
let physics;
|
|
118
|
+
try {
|
|
119
|
+
doc = store.readProse(headId);
|
|
120
|
+
row = store.row(headId);
|
|
121
|
+
physics = store.physicsOf(headId);
|
|
122
|
+
} catch {
|
|
123
|
+
return empty;
|
|
124
|
+
}
|
|
125
|
+
const g = gistOfDoc(doc, 120);
|
|
126
|
+
|
|
127
|
+
const points: { role: string; id: string; text: string }[] = [];
|
|
128
|
+
const push = (role: string, target: unknown): void => {
|
|
129
|
+
if (typeof target !== "string") return;
|
|
130
|
+
const rr = reveal(store, target, 80);
|
|
131
|
+
points.push({ role, id: target, text: rr.text ?? rr.label });
|
|
132
|
+
};
|
|
133
|
+
if (row?.superseded_by !== null && row?.superseded_by !== undefined) push("became", row.superseded_by);
|
|
134
|
+
push("hangs on", doc.meta["entityId"]);
|
|
135
|
+
push("revised", doc.meta["updates"]);
|
|
136
|
+
const grounded = doc.meta["groundedIn"];
|
|
137
|
+
if (Array.isArray(grounded)) for (const gid of grounded) push("grounded in", gid);
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
found: true,
|
|
141
|
+
id: headId,
|
|
142
|
+
headId,
|
|
143
|
+
askedFor: headId === id ? null : id,
|
|
144
|
+
journal: row === undefined ? false : isJournal(row),
|
|
145
|
+
title: doc.title ?? "",
|
|
146
|
+
// The BODY is the memory, and this is the owner's own window onto their own
|
|
147
|
+
// store (constitution line 6). A confidential body is the one exception, and
|
|
148
|
+
// it is withheld here exactly as it is withheld in recall.
|
|
149
|
+
text: g.confidential ? WITHHELD : doc.body.trim(),
|
|
150
|
+
confidential: g.confidential,
|
|
151
|
+
revision: row?.revision ?? 0,
|
|
152
|
+
// A hash of a withheld body is a derivative of withheld text, on the one
|
|
153
|
+
// surface whose job is withholding it. It is a confirmation oracle for an
|
|
154
|
+
// exactly-guessed secret rather than a way to recover one, but this is the
|
|
155
|
+
// wrong place to be interesting. The modal renders `""` as `—`.
|
|
156
|
+
contentHash: g.confidential ? "" : (row?.content_hash ?? ""),
|
|
157
|
+
kind: physics.kind,
|
|
158
|
+
band: band(physics, day),
|
|
159
|
+
recordedBand: `${row?.band ?? "—"} (set day ${row?.band_day ?? "—"})`,
|
|
160
|
+
strength: strength(physics, day),
|
|
161
|
+
salience: {
|
|
162
|
+
relevance: physics.salience.relevance,
|
|
163
|
+
emotional: physics.salience.emotional,
|
|
164
|
+
predictive: physics.salience.predictive,
|
|
165
|
+
novelty: physics.salience.novelty,
|
|
166
|
+
claimed: physics.salience.claimed ?? null,
|
|
167
|
+
combined: sal(physics.salience),
|
|
168
|
+
},
|
|
169
|
+
repetition: rep(physics),
|
|
170
|
+
uses: physics.uses,
|
|
171
|
+
reinforcedDays: physics.reinforcedDays ?? 0,
|
|
172
|
+
bornDay: physics.birthDay,
|
|
173
|
+
lastUsedDay: physics.lastUsedDay,
|
|
174
|
+
learnedOn: doc.learnedOn,
|
|
175
|
+
happenedOn: doc.happenedOn ?? null,
|
|
176
|
+
consolidated: physics.consolidated === true,
|
|
177
|
+
promoted: physics.promotedIdentity === true,
|
|
178
|
+
protected: physics.protected === true,
|
|
179
|
+
pressure: physics.pressure,
|
|
180
|
+
bar: physics.pressure > 0 ? barFor(src, headId) : null,
|
|
181
|
+
archived: row?.archived === 1 ? (row.archived_reason ?? "archived") : null,
|
|
182
|
+
removal: store.removalRecord(headId).map((x) => ({ stage: x.stage, actor: x.actor, reason: x.reason, at: x.at })),
|
|
183
|
+
edges: store.edgesFrom(headId).map((edge) => {
|
|
184
|
+
const rr = reveal(store, edge.dst, 72);
|
|
185
|
+
return { id: edge.dst, text: rr.text ?? rr.label, weight: edge.weight, confidential: rr.confidential };
|
|
186
|
+
}),
|
|
187
|
+
points,
|
|
188
|
+
versions: store.versions(headId).map((v) => ({
|
|
189
|
+
seq: v.seq,
|
|
190
|
+
reason: v.reason,
|
|
191
|
+
day: v.version_day,
|
|
192
|
+
became: v.successor_id === null ? "revised in place" : (reveal(store, v.successor_id, 72).label),
|
|
193
|
+
})),
|
|
194
|
+
prospective: store.prospectiveFor(headId).map((p) => ({
|
|
195
|
+
date: p.event_date,
|
|
196
|
+
state: p.state,
|
|
197
|
+
fires: p.fires,
|
|
198
|
+
precision: p.precision,
|
|
199
|
+
})),
|
|
200
|
+
absence: null,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function barFor(src: DashboardSource, id: string): number | null {
|
|
205
|
+
try {
|
|
206
|
+
return src.schemas.story(id).bar;
|
|
207
|
+
} catch {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/api/meta` — what this dashboard is pointed at.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `web/views.ts`, which re-exports every public name from here;
|
|
5
|
+
* the four rules in that file's header apply to every line below.
|
|
6
|
+
*/
|
|
7
|
+
import type { DashboardSource } from "../../source.js";
|
|
8
|
+
|
|
9
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
+
// meta — what this dashboard is pointed at
|
|
11
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export interface MetaView {
|
|
14
|
+
readonly dir: string;
|
|
15
|
+
readonly day: number;
|
|
16
|
+
readonly lastActive: string | null;
|
|
17
|
+
readonly observer: true;
|
|
18
|
+
readonly retentionDays: number;
|
|
19
|
+
/** True when nothing has ever been stored. The page says so on purpose. */
|
|
20
|
+
readonly empty: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* HOW MANY ROWS THE STORE HOLDS RIGHT NOW — a fingerprint, not a headline.
|
|
23
|
+
*
|
|
24
|
+
* An open page polls the event log to know whether anything happened, and
|
|
25
|
+
* that is a wrong question: a deposit that writes no durable event never moves
|
|
26
|
+
* the log's sequence, so a page left open reports the old count forever
|
|
27
|
+
* (design review, 2026-09-04 — the only wrong number left on any screen). This
|
|
28
|
+
* is the cheap thing a poll can compare to notice a deposit that left no trace
|
|
29
|
+
* in the log.
|
|
30
|
+
*
|
|
31
|
+
* The case that MOTIVATED it has since gone away: `counterparts note` was the
|
|
32
|
+
* example, and since `gate.deposit` (2026-09-05, replay §2a) the authored door
|
|
33
|
+
* writes a row like every other door, so a note moves the sequence and takes
|
|
34
|
+
* the event branch. This stays as the belt it always was — a store seeded
|
|
35
|
+
* around the door, a migration, any future write that leaves no row — and
|
|
36
|
+
* because a fingerprint that is only correct while one particular writer
|
|
37
|
+
* happens to log is not a fingerprint.
|
|
38
|
+
*
|
|
39
|
+
* It counts every row, including the journal and the archived, which is why
|
|
40
|
+
* it is not called `held`: nothing should ever render it as a memory count.
|
|
41
|
+
*/
|
|
42
|
+
readonly rows: number;
|
|
43
|
+
readonly generatedAt: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** An empty string is the store's "never moved", not a date. */
|
|
47
|
+
export function lastActive(raw: string | undefined): string | null {
|
|
48
|
+
return raw === undefined || raw.trim().length === 0 ? null : raw;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function metaView(src: DashboardSource): MetaView {
|
|
52
|
+
const store = src.store;
|
|
53
|
+
const rows = store.list().length;
|
|
54
|
+
return {
|
|
55
|
+
dir: store.dir,
|
|
56
|
+
day: store.livedDay(),
|
|
57
|
+
lastActive: lastActive(store.getMeta("lastActiveDate")),
|
|
58
|
+
observer: true,
|
|
59
|
+
retentionDays: store.retentionDays,
|
|
60
|
+
empty: rows === 0,
|
|
61
|
+
rows,
|
|
62
|
+
generatedAt: Date.now(),
|
|
63
|
+
};
|
|
64
|
+
}
|