counterparts 0.3.13 → 0.3.15

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +264 -0
  2. package/docs/QUICKSTART.md +22 -0
  3. package/docs/README.md +1 -0
  4. package/package.json +1 -1
  5. package/src/adapters/claude-code/CONTRACT.md +48 -0
  6. package/src/adapters/claude-code/NOTES.md +148 -0
  7. package/src/adapters/claude-code/bin/hook.mjs +4 -2
  8. package/src/adapters/claude-code/bin/hook.ts +61 -7
  9. package/src/adapters/claude-code/bin/nightly.ts +5 -1
  10. package/src/adapters/claude-code/bin/runner.ts +11 -3
  11. package/src/adapters/claude-code/claim.ts +319 -0
  12. package/src/adapters/claude-code/doctor.ts +170 -16
  13. package/src/adapters/claude-code/embed-client.ts +3 -0
  14. package/src/adapters/cli/CONTRACT.md +5 -0
  15. package/src/adapters/cli/NOTES.md +25 -0
  16. package/src/adapters/cli/bin/counterparts.mjs +4 -2
  17. package/src/adapters/cli/bin/counterparts.ts +49 -3
  18. package/src/adapters/cli/commands.ts +169 -32
  19. package/src/adapters/cli/desktop.ts +112 -7
  20. package/src/adapters/cli/help.ts +10 -0
  21. package/src/adapters/cli/index.ts +1 -0
  22. package/src/adapters/cli/install.ts +94 -14
  23. package/src/adapters/cli/self-page.ts +5 -8
  24. package/src/adapters/cli/settle.ts +39 -2
  25. package/src/adapters/cli/wire.ts +18 -1
  26. package/src/adapters/config.ts +29 -1
  27. package/src/adapters/dashboard/NOTES.md +33 -0
  28. package/src/adapters/dashboard/bin/dashboard.mjs +4 -2
  29. package/src/adapters/dashboard/bin/dashboard.ts +11 -3
  30. package/src/adapters/dashboard/index.ts +14 -0
  31. package/src/adapters/dashboard/registries.ts +3 -0
  32. package/src/adapters/dashboard/source.ts +0 -8
  33. package/src/adapters/dashboard/web/fired.ts +8 -0
  34. package/src/adapters/dashboard/web/flow.ts +1 -0
  35. package/src/adapters/dashboard/web/lanes.ts +1 -0
  36. package/src/adapters/dashboard/web/narrate.ts +11 -0
  37. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -1
  38. package/src/adapters/dashboard/web/pages/health/sections/cycle.js +7 -10
  39. package/src/adapters/dashboard/web/pages/memories/memories.css +3 -0
  40. package/src/adapters/dashboard/web/pages/memories/row.js +5 -2
  41. package/src/adapters/dashboard/web/pages/memories/sections/hold.js +2 -1
  42. package/src/adapters/dashboard/web/pages/memories/sections/search.js +19 -3
  43. package/src/adapters/dashboard/web/server.ts +16 -4
  44. package/src/adapters/dashboard/web/shared/dates.js +6 -16
  45. package/src/adapters/dashboard/web/shared/memory-modal.js +21 -8
  46. package/src/adapters/dashboard/web/views/health.ts +19 -5
  47. package/src/adapters/dashboard/web/views/mechanism-panel.ts +8 -5
  48. package/src/adapters/dashboard/web/views/memories.ts +26 -7
  49. package/src/adapters/dashboard/web/views/memory-words.ts +16 -0
  50. package/src/adapters/dashboard/web/views/memory.ts +51 -2
  51. package/src/adapters/dashboard/web/views/mind.ts +38 -6
  52. package/src/adapters/empty-bunfig.toml +5 -0
  53. package/src/adapters/fired.ts +16 -2
  54. package/src/adapters/host-wiring.ts +112 -17
  55. package/src/adapters/log/index.ts +2 -2
  56. package/src/adapters/mcp/CONTRACT.md +17 -2
  57. package/src/adapters/mcp/INTERFACE-GAPS.md +15 -1
  58. package/src/adapters/mcp/NOTES.md +269 -0
  59. package/src/adapters/mcp/bin/serve.mjs +4 -2
  60. package/src/adapters/mcp/bin/serve.ts +17 -6
  61. package/src/adapters/mcp/facts.ts +72 -4
  62. package/src/adapters/mcp/meaning.ts +218 -15
  63. package/src/adapters/mcp/server.ts +21 -6
  64. package/src/adapters/mcp/tools.ts +86 -61
  65. package/src/adapters/plugin-run.sh +413 -34
  66. package/src/adapters/plugin.ts +141 -17
  67. package/src/adapters/runtime.ts +192 -17
  68. package/src/adapters/sessions.ts +2 -2
  69. package/src/core/associate/NOTES.md +10 -0
  70. package/src/core/bridge.ts +1 -1
  71. package/src/core/briefing.ts +20 -3
  72. package/src/core/contradictions.ts +56 -20
  73. package/src/core/counterpart.ts +72 -23
  74. package/src/core/dream/CONTRACT.md +6 -14
  75. package/src/core/dream/INTERFACE-GAPS.md +3 -2
  76. package/src/core/dream/NOTES.md +10 -0
  77. package/src/core/dream/index.ts +11 -53
  78. package/src/core/dream/reflect.ts +11 -2
  79. package/src/core/embed/static.ts +5 -1
  80. package/src/core/encode/INTERFACE-GAPS.md +2 -1
  81. package/src/core/encode/NOTES.md +12 -0
  82. package/src/core/encode/chunk.ts +6 -30
  83. package/src/core/encode/index.ts +0 -1
  84. package/src/core/encode/types.ts +1 -13
  85. package/src/core/handoff/INTERFACE-GAPS.md +1 -1
  86. package/src/core/handoff/index.ts +2 -1
  87. package/src/core/handoff/last-here.ts +18 -2
  88. package/src/core/physics/CONTRACT.md +6 -0
  89. package/src/core/physics/NOTES.md +33 -2
  90. package/src/core/physics/index.ts +22 -7
  91. package/src/core/prospective/CONTRACT.md +3 -1
  92. package/src/core/prospective/NOTES.md +15 -0
  93. package/src/core/recall/activate.ts +1 -1
  94. package/src/core/recall/time-ask.ts +173 -19
  95. package/src/core/self/CONTRACT.md +56 -19
  96. package/src/core/self/NOTES.md +172 -0
  97. package/src/core/self/behind.ts +6 -3
  98. package/src/core/self/briefing.ts +384 -28
  99. package/src/core/self/index.ts +105 -44
  100. package/src/core/self/page.ts +12 -85
  101. package/src/core/self/tunables.ts +16 -19
  102. package/src/core/self/writer.ts +31 -4
  103. package/src/core/sleep/NOTES.md +32 -0
  104. package/src/core/store/NOTES.md +21 -2
  105. package/src/core/store/index.ts +2 -1
  106. package/src/core/time.ts +15 -0
@@ -1,19 +1,16 @@
1
1
  /* The last sleep cycle, as one line with a dot per step. */
2
- import { dateWords, localIso } from "../../../shared/dates.js";
2
+ import { dateWords } from "../../../shared/dates.js";
3
3
  import { $, esc } from "../../../shared/dom.js";
4
4
 
5
5
  export const markup = `
6
6
  <div class="card pad hcy" id="h-cycle"></div>`;
7
7
 
8
- function sameLocalDay(ms) {
9
- const a = new Date(ms);
10
- const b = new Date();
11
- return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
12
- }
13
-
14
- function when(c) {
15
- if (c.at !== null && sameLocalDay(c.at)) return "today";
16
- if (c.at !== null) return "on " + dateWords(localIso(c.at)) + " (lived day " + c.day + ")";
8
+ /* The day comes dated from the server, in the person's zone (`views/health.ts`,
9
+ `cycle.on` and `cycle.today`), so it agrees with every other date on the
10
+ page; it read the browser's calendar until 2026-10-09. */
11
+ export function when(c) {
12
+ if (c.today) return "today";
13
+ if (c.on) return "on " + (dateWords(c.on) || c.on) + " (lived day " + c.day + ")";
17
14
  return "on lived day " + c.day;
18
15
  }
19
16
 
@@ -46,6 +46,8 @@
46
46
  /* An answer's quieter notes, on their own line under its head (what it is
47
47
  about, a time it named, what it left out and why). */
48
48
  .find-note{display:block;color:var(--faint);font-size:12px;margin-top:2px}
49
+ /* A name asked about with no card, said before the head (2026-10-09). */
50
+ .find-lead{display:block;color:var(--text);margin-bottom:2px}
49
51
 
50
52
  /* ── the two small pictures: how well I remember, how it feels ── */
51
53
  .glance2{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,24rem),1fr));gap:0 20px;align-items:stretch}
@@ -155,6 +157,7 @@
155
157
  .mdate{color:var(--faint);font-size:12px;white-space:nowrap}
156
158
  .mkind{display:inline-flex;align-items:center;gap:5px;color:var(--faint);font-size:12px;white-space:nowrap}
157
159
  .mfading{color:var(--amber);font-size:12px;white-space:nowrap}
160
+ .mrepeats{color:var(--dim);font-size:12px;white-space:nowrap}
158
161
  /* The close matches' heading, under the exact ones (M4). */
159
162
  .mclose-h{padding:9px 15px 7px;border-bottom:1px solid var(--border);color:var(--ink);font-size:12.5px;font-weight:600;background:rgba(255,255,255,.02)}
160
163
  .mclose-h span{color:var(--dim);font-weight:400}
@@ -2,7 +2,8 @@
2
2
  Title on its own line with the words dimmer beneath (two lines, clipped); the
3
3
  date, the kind and the marks on the right. Every row is drawn at the same
4
4
  brightness (round 4, 2026-09-28): how well it is remembered shows only when
5
- it is not the usual — the one word "fading". A plain fact carries no kind
5
+ it is not the usual — the one word "fading", or for a date that still
6
+ repeats, how often ("repeats every May 14"). A plain fact carries no kind
6
7
  tag (the quiet default); a journal chapter is titled by its day. An id
7
8
  written inside the words is a small link to that memory (2026-10-09). */
8
9
  import { esc } from "../../shared/dom.js";
@@ -108,7 +109,9 @@ export function memRow(r, opts = {}) {
108
109
  // A plain fact is the quiet default: no tag. A journal chapter says so in its title.
109
110
  const kindTag = !r.kind || (r.kind === "fact" && !r.schemaRole) || r.journal ? ""
110
111
  : '<span class="mkind" title="' + esc(kindWords) + '">' + kindMark(r.kind, false) + '<span class="klabel">' + esc(kindWords) + "</span></span>";
111
- const held = r.hold === "fading" ? '<span class="mfading" title="unless it is used, I may put it away within my next two weeks of use">fading</span>' : "";
112
+ // A date that still repeats is kept for its next time, however faint (2026-10-09): it is never "fading", and says how often instead.
113
+ const held = r.hold === "fading" ? '<span class="mfading" title="unless it is used, I may put it away within my next two weeks of use">fading</span>'
114
+ : r.repeats ? '<span class="mrepeats" title="' + esc("it comes round " + r.repeats + ", so I'll keep it while it does") + '">repeats ' + esc(r.repeats) + "</span>" : "";
112
115
  const date = r.date && !r.journal
113
116
  ? '<span class="mdate" title="' + esc(DATE_WORDS[r.dateFrom] || "") + '">' + esc(dateOr(r.date)) + "</span>" : "";
114
117
  const put = r.archived
@@ -14,7 +14,8 @@ import { filters, onFilter, toggle } from "../state.js";
14
14
  * [key, words, what it means]. True to the forgetting rules (`views/memories.ts#holdOf`,
15
15
  * `physics`): firm is still settled into what I know 30 lived days on if unused
16
16
  * (and a lived day is never shorter than a calendar day); fading is what prune
17
- * could let go within 14 lived days, unless a revision still leans on it.
17
+ * could let go within 14 lived days, unless a revision still leans on it. A
18
+ * date that still repeats is kept by prune, so it is never fading (2026-10-09).
18
19
  */
19
20
  export const PARTS = [
20
21
  ["firm", "firm", "I'll still know these a month from now, even if they're never used."],
@@ -293,12 +293,21 @@ export function factLines(m) {
293
293
  parts.push(/^(mem|epi|sch)_/.test(m.now || "") ? "an earlier version — now " + withIdMarks(m.now) : "an earlier version — a later one holds now");
294
294
  }
295
295
  for (const s of m.standing || []) parts.push(withIdMarks(s));
296
- if (m.corrected > 0) parts.push(esc(plural(m.corrected, "corrected version") + " hidden"));
296
+ // Corrected versions were wrong: each named and linked like an earlier one,
297
+ // labelled so (`facts.ts#itemLines`); the rest counted.
298
+ const wrong = m.correctedShown || [];
299
+ const unnamed = (m.corrected || 0) - wrong.length;
300
+ if (unnamed > 0 && wrong.length === 0) parts.push(esc(plural(unnamed, "corrected version") + " hidden"));
297
301
  const earlier = (m.earlier || []).map((e) =>
298
302
  '<div class="mearlier">earlier: “' + esc(e.text) + "”" +
299
303
  esc((e.learned ? " (learned " + dateOr(e.learned) + ")" : "") + (e.changed ? ", changed " + dateOr(e.changed) : "")) +
300
304
  (e.id ? " " + withIdMarks(e.id) : "") + "</div>").join("") +
301
- (m.earlierMore > 0 ? '<div class="mearlier">+' + m.earlierMore + " more earlier</div>" : "");
305
+ (m.earlierMore > 0 ? '<div class="mearlier">+' + m.earlierMore + " more earlier</div>" : "") +
306
+ wrong.map((e) =>
307
+ '<div class="mearlier">corrected (was wrong): “' + esc(e.text) + "”" +
308
+ esc((e.learned ? " (learned " + dateOr(e.learned) + ")" : "") + (e.corrected ? ", corrected " + dateOr(e.corrected) : "")) +
309
+ " " + withIdMarks(e.id) + "</div>").join("") +
310
+ (unnamed > 0 && wrong.length > 0 ? '<div class="mearlier">+' + unnamed + " more corrected (was wrong)</div>" : "");
302
311
  if (parts.length === 0 && !earlier) return "";
303
312
  return '<div class="mfacts">' + (parts.length > 0 ? "<div>" + parts.join(" · ") + "</div>" : "") + earlier + "</div>";
304
313
  }
@@ -331,8 +340,15 @@ export function factsRows(r, q) {
331
340
  return rows + faded;
332
341
  }
333
342
 
334
- /** A meaning answer's head: what it is about, how much holds it, then the quieter notes. Markup. */
343
+ /** A name asked about that has no card (`MeaningResult.noCard`), said first, on its own line. */
344
+ const leadLine = (r) => (r.noCard ? '<span class="find-lead">' + esc(r.noCard) + ".</span>" : "");
345
+
346
+ /** A meaning answer's head: a name with no card first, then what it is about, how much holds it, then the quieter notes. Markup. */
335
347
  export function meaningHead(r) {
348
+ return leadLine(r) + meaningHeadLine(r);
349
+ }
350
+
351
+ function meaningHeadLine(r) {
336
352
  if (r.lens === null) return esc("nothing came");
337
353
  const c = r.counts;
338
354
  const parts = [r.lens.name];
@@ -60,11 +60,11 @@
60
60
  import { readFileSync } from "node:fs";
61
61
  import { createServer } from "node:http";
62
62
  import type { IncomingMessage, Server, ServerResponse } from "node:http";
63
- import { dirname, join } from "node:path";
64
- import { fileURLToPath } from "node:url";
63
+ import { join } from "node:path";
65
64
 
66
65
  import { ownerNames } from "../../../core/sleep/index.js";
67
66
  import { dataDir, isStoreError } from "../../../core/store/index.js";
67
+ import { zoneBeside, zoneOfConfig } from "../../config.js";
68
68
  import { Dashboard } from "../index.js";
69
69
  import { upgradePending, upgradePendingSentence } from "../upgrade.js";
70
70
  import type { DashboardSource } from "../source.js";
@@ -82,6 +82,7 @@ import { mechanismPanel } from "./views/mechanism-panel.js";
82
82
  import { mechanismsView } from "./views/mechanisms.js";
83
83
  import { DREAM_LIMIT, dreamsView } from "./views/dreams.js";
84
84
  import { resolveStatic } from "./static.js";
85
+ import { packagePath } from "../../runtime.js";
85
86
  import {
86
87
  activityView,
87
88
  eventDetail,
@@ -102,7 +103,9 @@ import {
102
103
  export const DEFAULT_PORT = 4747;
103
104
  export const PORT_ENV = "COUNTERPARTS_DASHBOARD_PORT";
104
105
 
105
- const HERE = dirname(fileURLToPath(import.meta.url));
106
+ // From the package root rather than `import.meta.url`, which in the single
107
+ // binary is the binary's own path, not this module's (adapters/runtime.ts).
108
+ const HERE = packagePath("src/adapters/dashboard/web");
106
109
  const APP_PATH = join(HERE, "app.html");
107
110
 
108
111
  const NO_STORE = { "cache-control": "no-store" } as const;
@@ -384,7 +387,16 @@ function resolvePort(opts: ServeOptions): number {
384
387
  * for 0 — and closing it closes the store.
385
388
  */
386
389
  export function startDashboard(opts: ServeOptions = {}): Promise<RunningDashboard> {
387
- const openOpts = opts.dir === undefined ? {} : { dir: opts.dir };
390
+ // THE ZONE THE HOOKS USE (review of #335, 2026-10-09): the named
391
+ // configuration's `timeZone`, else the one beside the store, else the
392
+ // machine's. Every date the server sends is read in it, already local.
393
+ const timeZone =
394
+ (opts.config === undefined ? undefined : zoneOfConfig(opts.config)) ??
395
+ (opts.dir === undefined ? undefined : zoneBeside(opts.dir));
396
+ const openOpts = {
397
+ ...(opts.dir === undefined ? {} : { dir: opts.dir }),
398
+ ...(timeZone === undefined ? {} : { timeZone }),
399
+ };
388
400
  // A store waiting for its upgrade is not an error to the owner: the server
389
401
  // still starts, says so on every page, and tries the store again on each
390
402
  // request, so a reload after a session has upgraded it shows the dashboard.
@@ -7,7 +7,6 @@
7
7
 
8
8
  const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
9
9
  const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
10
- const ISO = /^(\d{4})-(\d{2})-(\d{2})/;
11
10
 
12
11
  /** 1 → "1st", 2 → "2nd", 11 → "11th", 23 → "23rd". */
13
12
  export function ordinal(n) {
@@ -38,18 +37,9 @@ export function dateOr(value, opts) {
38
37
  return dateWords(value, opts) || String(value || "");
39
38
  }
40
39
 
41
- /** A full timestamp (`2026-09-30T17:47:03.000Z`) → "Sep 30th, 2026, 17:47 UTC". */
42
- export function stampWords(isoStamp) {
43
- const s = String(isoStamp || "");
44
- const m = ISO.exec(s);
45
- const day = m ? dateWords(m[0], { year: true }) : null;
46
- const t = /T(\d{2}:\d{2})/.exec(s);
47
- return day ? day + (t ? ", " + t[1] + " UTC" : "") : s;
48
- }
49
-
50
- /** A clock reading (ms) → the day it falls on HERE, as `YYYY-MM-DD`. */
51
- export function localIso(ms) {
52
- const d = new Date(ms);
53
- const two = (n) => String(n).padStart(2, "0");
54
- return d.getFullYear() + "-" + two(d.getMonth() + 1) + "-" + two(d.getDate());
55
- }
40
+ /* No moment is turned into a day in here (2026-10-09). `stampWords` (a UTC
41
+ minute) and `localIso` (the browser's calendar) were removed: the server
42
+ dates every moment in the person's zone, the one the hooks use
43
+ (`views/memory.ts#writtenWhen`, `views/health.ts`'s `cycle.on`), and the
44
+ page prints the day it is handed. A browser's own zone can differ from the
45
+ configured one, and one page then showed two days for one moment. */
@@ -13,7 +13,7 @@ import { emptyBox } from "./absence.js";
13
13
  import { esc } from "./dom.js";
14
14
  import { headline, n2, n3, said } from "./format.js";
15
15
  import { coreRoadLine, curveStart, versionRows } from "./memory-card-words.js";
16
- import { dateOr, localIso, stampWords } from "./dates.js";
16
+ import { dateOr, dateWords } from "./dates.js";
17
17
  import { FEELING_COLOURS, feelingName, feelingWord, kindMark, kindOf } from "./memory-marks.js";
18
18
  import { openModal } from "./modal.js";
19
19
  import { confirmTyped } from "./widgets/confirm.js";
@@ -48,12 +48,19 @@ export function memoryCard(d) {
48
48
  }
49
49
 
50
50
  /** The day it was written, once: "Written Sep 28th, 2026" — the moment it entered
51
- * the store (v7 `created_at`) on this computer's calendar, else the calendar day
52
- * it was recorded. It read the UTC day until 2026-10-09, which put a memory
53
- * written on a Denver evening on the next day. */
51
+ * the store (v7 `created_at`) on the person's calendar, else the calendar day
52
+ * it was recorded. The server dates it (`views/memory.ts#writtenWhen`), in the
53
+ * zone the hooks use, so the card agrees with every other date the dashboard
54
+ * prints. It read the UTC day until 2026-10-09, then the browser's. */
54
55
  export function writtenOn(d) {
55
- if (typeof d.createdAt === "number" && d.createdAt > 0) return localIso(d.createdAt);
56
- return /^\d{4}-\d{2}-\d{2}$/.test(String(d.learnedOn || "")) ? d.learnedOn : null;
56
+ return /^\d{4}-\d{2}-\d{2}$/.test(String(d.writtenOn || "")) ? d.writtenOn : null;
57
+ }
58
+
59
+ /** The details row's "written": its day and its clock, named — "Sep 30th, 2026, 11:47 MDT". */
60
+ export function writtenStamp(d) {
61
+ const day = writtenOn(d);
62
+ if (!day || !d.writtenClock) return null;
63
+ return (dateWords(day, FULL) || day) + ", " + d.writtenClock;
57
64
  }
58
65
 
59
66
  /** The card is read on its own, so its dates always carry their year. */
@@ -97,9 +104,15 @@ function curvePart(d) {
97
104
  }
98
105
 
99
106
  /** The one plain sentence under the chart (round 4): "I remember this at 41%.
100
- * If nobody uses it, I'll put it away around day 67." `c` is the card's curve. */
107
+ * If nobody uses it, I'll put it away around day 67." `c` is the card's curve.
108
+ * The prune never lets a protected memory go (review of #343): "It's protected, so
109
+ * I'll keep it even if nobody uses it." A date that still repeats is kept for
110
+ * its next time (2026-10-09), however faint: "It comes round every May 14, so
111
+ * I'll keep it while it does." Both come before "soon": neither is. */
101
112
  export function rememberLine(now, c) {
102
113
  const head = "I remember this at " + pct(now) + ". ";
114
+ if (c.protected) return head + "It's protected, so I'll keep it even if nobody uses it.";
115
+ if (c.repeats) return head + "It comes round " + c.repeats + ", so I'll keep it while it does.";
103
116
  if (c.archiveDay !== null) return head + "If nobody uses it, I'll put it away around day " + c.archiveDay + ".";
104
117
  if (now < c.archiveLine) return head + "That's low enough that I could put it away soon.";
105
118
  const ahead = c.to - c.day;
@@ -266,7 +279,7 @@ function footer(d) {
266
279
  kv("lived", "born day " + d.bornDay + " · used " + d.uses + "× over " + d.reinforcedDays + " days · last used day " + d.lastUsedDay) +
267
280
  kv("standing", (d.consolidated ? "consolidated" : "not consolidated") + " · " + (d.promoted ? "promoted" : "not promoted") +
268
281
  " · " + (d.protected ? "protected" : "revisable") + " · pressure " + n3(d.pressure) + (d.bar === null ? "" : " / bar " + n3(d.bar))) +
269
- (d.createdAt ? kv("written", esc(stampWords(new Date(d.createdAt).toISOString()))) : "") +
282
+ (writtenStamp(d) ? kv("written", esc(writtenStamp(d))) : "") +
270
283
  (d.archived ? kv("archived", esc(d.archived)) : "") +
271
284
  d.points.map((p) => kv(p.role, esc(p.id))).join("") +
272
285
  d.removal.map((r) => kv("removal", esc(r.stage) + " by " + esc(r.actor) + " — " + esc(r.reason || "no reason recorded"))).join("") +
@@ -11,6 +11,7 @@ import { MARKER_UNSET, MERGE_ARCHIVE_REASON, PRUNE_ARCHIVE_REASON, readMarker }
11
11
  import { cadenceFor, markerDue } from "../../../../core/sleep/markers.js";
12
12
  import type { Phase } from "../../../../core/sleep/types.js";
13
13
  import type { Kind } from "../../../../core/types.js";
14
+ import { localDate } from "../../../../core/time.js";
14
15
  import { NEVER, NONE } from "../../layout.js";
15
16
  import { CYCLE_PHASES, DURABLE_EVENTS, DURABLE_EVENT_NAMES, KINDS } from "../../registries.js";
16
17
  import type { DurableEventName } from "../../registries.js";
@@ -64,6 +65,13 @@ export interface HealthView {
64
65
  readonly cycle: {
65
66
  readonly day: number | null;
66
67
  readonly at: number | null;
68
+ /**
69
+ * `at`'s calendar day in the person's zone (`store.zone()`), and whether it
70
+ * is today there — dated by the server, so the line agrees with every
71
+ * other date on the page (review of #335, 2026-10-09). Null with `at`.
72
+ */
73
+ readonly on: string | null;
74
+ readonly today: boolean;
67
75
  readonly ran: number;
68
76
  /** Phases that did not run because their cadence had not come round: not a problem. */
69
77
  readonly waiting: number;
@@ -123,9 +131,10 @@ export interface WakeBudget {
123
131
  * it is green; amber only when being full cost something, and the amber names
124
132
  * it). Each from a record that already exists:
125
133
  *
126
- * page — the published wake itself: a page cut to fit carries
127
- * `page.ts#truncationMarker`, and a page with no room at all is
128
- * replaced by `briefing.ts#pageTooLargeLine`. Both name bytes.
134
+ * page — the published wake itself: a page with no room for it
135
+ * whole is replaced by `briefing.ts#pageTooLargeLine`; a wake
136
+ * published before 2026-10-09 may carry a cut page's
137
+ * `page.ts#truncationMarker` instead. Both name bytes.
129
138
  * handoffs — `handoff.refused` rows with reason `no-room` (durable, one per
130
139
  * handoff per lived day) since the published wake was rendered:
131
140
  * how many distinct handoffs a session start could not carry.
@@ -151,9 +160,11 @@ export interface WakeCosts {
151
160
  readonly writerHeld: boolean;
152
161
  }
153
162
 
154
- /** `page.ts#truncationMarker` and `briefing.ts#pageTooLargeLine`, as the wake prints them. */
163
+ /** `page.ts#truncationMarker` (a wake published before 2026-10-09, when the
164
+ * page could be cut) and `briefing.ts#pageTooLargeLine` ("whole" since then),
165
+ * as the wake prints them. */
155
166
  const PAGE_CUT = /\[This page is (\d+) bytes; the wake shows the first (\d+)\./;
156
- const PAGE_LEFT_OUT = /\(My page is (\d+) bytes — no room for it in this wake\./;
167
+ const PAGE_LEFT_OUT = /\(My page is (\d+) bytes — no room for it (?:whole )?in this wake\./;
157
168
 
158
169
  /** The self page's cost, read off the published wake's own words. Pure. */
159
170
  export function pageCostOf(text: string): WakeCosts["page"] {
@@ -388,9 +399,12 @@ export function healthView(src: DashboardSource): HealthView {
388
399
  const nextInDays = state === "waiting" && p.day !== null ? Math.max(0, p.day + cadence - day) : null;
389
400
  return { phase: p.phase, gloss: PHASE_GLOSS[p.phase] ?? p.phase, state, day: p.day, nextInDays };
390
401
  });
402
+ const cycleOn = lastCycleRow === undefined ? null : localDate(lastCycleRow.at, store.zone()) || null;
391
403
  const cycle = {
392
404
  day: newest,
393
405
  at: lastCycleRow === undefined ? null : lastCycleRow.at,
406
+ on: cycleOn,
407
+ today: cycleOn !== null && cycleOn === store.today(),
394
408
  ran: cyclePhases.filter((p) => p.state === "ran").length,
395
409
  waiting: cyclePhases.filter((p) => p.state === "waiting").length,
396
410
  total: cyclePhases.length,
@@ -773,15 +773,18 @@ export function fadeCurve(
773
773
  /**
774
774
  * The first lived day within `horizon` days ahead on which prune's own verdict
775
775
  * (`physics#pruneVerdict`: under the floor, long enough unused, episodic, not
776
- * protected) would let this memory go if nobody used it — or null. The
777
- * revision-chain gate is not checked here (it needs the store), so this can
778
- * only say "sooner than it will be", never "later".
776
+ * protected, not a date that still repeats) would let this memory go if nobody
777
+ * used it — or null. `recurring` is the row's own repeat (`store#recurrenceOfRow`
778
+ * !== null), passed the way `sleep/prune.ts` passes it, so a live repeat never
779
+ * has a let-go day (2026-10-09). The revision-chain gate is not checked here
780
+ * (it needs the store), so this can only say "sooner than it will be", never
781
+ * "later".
779
782
  */
780
- export function letGoDay(physics: MemoryPhysics, day: number, horizon: number): number | null {
783
+ export function letGoDay(physics: MemoryPhysics, day: number, horizon: number, recurring = false): number | null {
781
784
  // Unused, strength only falls: still over the floor at the horizon means never inside it.
782
785
  if (strength(physics, day + horizon) >= TUNABLES.PHI_PRUNE) return null;
783
786
  for (let d = day; d <= day + horizon; d++) {
784
- if (pruneVerdict(physics, d, { inLiveRevisionChain: false }).prune) return d;
787
+ if (pruneVerdict(physics, d, { inLiveRevisionChain: false, recurring }).prune) return d;
785
788
  }
786
789
  return null;
787
790
  }
@@ -18,7 +18,7 @@ import { displayName } from "../ask-voice.js";
18
18
  import { WITHHELD, revealHere } from "../reveal.js";
19
19
  import { archiveWords } from "./archive-words.js";
20
20
  import { letGoDay } from "./mechanism-panel.js";
21
- import { feelingsShown, firstSentence, isChapterMemory, shownOf } from "./memory-words.js";
21
+ import { feelingsShown, firstSentence, isChapterMemory, repeatsOf, shownOf } from "./memory-words.js";
22
22
  import type { DateFrom, FeelingShown } from "./memory-words.js";
23
23
  import { absenceFor, census, countMap } from "./shared.js";
24
24
  import { todayView } from "./today.js";
@@ -107,12 +107,15 @@ export const FIRM_AHEAD_DAYS = 30;
107
107
  * Firm, settling or fading. Core and protected memories are firm (neither is
108
108
  * pruned). Fading is prune's own verdict within `NEAR_LET_GO_DAYS` (`letGoDay`);
109
109
  * an entity card is faded by `schemas/`, not by prune, so it is never fading
110
- * here. Firm is still settled `FIRM_AHEAD_DAYS` from now if unused. The rest
111
- * are settling.
110
+ * here. Nor is a memory whose date still repeats (`opts.recurring`, the row's
111
+ * `recurrenceOfRow` — 2026-10-09): the prune keeps it for its next occurrence,
112
+ * so it is firm or settling by its strength like any other, and the row says
113
+ * how often it comes round (`ListRow.repeats`). Firm is still settled
114
+ * `FIRM_AHEAD_DAYS` from now if unused. The rest are settling.
112
115
  */
113
- export function holdOf(physics: MemoryPhysics, day: number, opts: { prunable: boolean }): Hold {
116
+ export function holdOf(physics: MemoryPhysics, day: number, opts: { prunable: boolean; recurring?: boolean }): Hold {
114
117
  if (physics.promotedIdentity === true || physics.protected === true) return "firm";
115
- if (opts.prunable && letGoDay(physics, day, NEAR_LET_GO_DAYS) !== null) return "fading";
118
+ if (opts.prunable && letGoDay(physics, day, NEAR_LET_GO_DAYS, opts.recurring === true) !== null) return "fading";
116
119
  if (strengthOf(physics, day + FIRM_AHEAD_DAYS) >= PHYSICS.THETA_SEM) return "firm";
117
120
  return "settling";
118
121
  }
@@ -177,7 +180,12 @@ export function memoriesView(src: DashboardSource, opts: { limit?: number } = {}
177
180
  else if (m.unreadable) hold.settling += 1;
178
181
  else {
179
182
  try {
180
- hold[holdOf(store.physicsOf(m.id), day, { prunable: row === undefined || !isEntityCard(row) })] += 1;
183
+ hold[
184
+ holdOf(store.physicsOf(m.id), day, {
185
+ prunable: row === undefined || !isEntityCard(row),
186
+ recurring: row !== undefined && repeatsOf(row) !== null,
187
+ })
188
+ ] += 1;
181
189
  } catch {
182
190
  hold.settling += 1;
183
191
  }
@@ -329,6 +337,10 @@ export interface ListRow {
329
337
  readonly createdAt: number | null;
330
338
  /** How firmly it is held (`holdOf`); null for an archived row or a journal chapter. */
331
339
  readonly hold: Hold | null;
340
+ /** A live row whose date still repeats: how often, as a person says it
341
+ * (`every May 14`, `repeatsOf`) — kept for its next occurrence, so never
342
+ * "fading" (2026-10-09). Null otherwise, and on a withheld row. */
343
+ readonly repeats: string | null;
332
344
  /** Put-away rows only: how many put-away versions of the same memory this
333
345
  * one row stands for (itself included) — 1 for most. See `versionKey`. */
334
346
  readonly versions: number;
@@ -483,6 +495,7 @@ export function memoryListView(
483
495
  core: boolean;
484
496
  journal: boolean;
485
497
  hold: Hold | null;
498
+ repeats: string | null;
486
499
  /** Put-away rows only: the key its other versions share, or null. */
487
500
  group: string | null;
488
501
  versions: number;
@@ -503,11 +516,13 @@ export function memoryListView(
503
516
  let s = 0;
504
517
  const chapter = isChapterMemory(row);
505
518
  let hold: Hold | null = null;
519
+ // Kept while it repeats (the prune's `recurring` gate): live rows only.
520
+ const repeats = isArchived || chapter ? null : repeatsOf(row);
506
521
  try {
507
522
  const physics = rowToPhysics(row);
508
523
  b = bandOf(physics, day);
509
524
  s = strengthOf(physics, day);
510
- if (!isArchived && !chapter) hold = holdOf(physics, day, { prunable: !isEntityCard(row) });
525
+ if (!isArchived && !chapter) hold = holdOf(physics, day, { prunable: !isEntityCard(row), recurring: repeats !== null });
511
526
  } catch {
512
527
  /* a row whose physics will not compute still lists, at zero */
513
528
  if (!isArchived && !chapter) hold = "settling";
@@ -524,6 +539,7 @@ export function memoryListView(
524
539
  core: row.promoted_identity === 1,
525
540
  journal: chapter,
526
541
  hold,
542
+ repeats,
527
543
  group: isArchived ? versionKey(store, row) : null,
528
544
  versions: 1,
529
545
  cores: new Set(feelingsShown(store, id).map((f) => f.core)),
@@ -621,6 +637,9 @@ export function memoryListView(
621
637
  feelings: feelingsShown(store, r.id),
622
638
  createdAt: r.createdAt,
623
639
  hold: r.hold,
640
+ // A withheld row shows no date of its own in the list, so not how often
641
+ // its date comes round either; it is still never "fading".
642
+ repeats: here.confidential || !here.present ? null : r.repeats,
624
643
  versions: r.versions,
625
644
  };
626
645
  });
@@ -9,7 +9,9 @@
9
9
  */
10
10
  import { wheelEntry } from "../../../../core/feelings-wheel.js";
11
11
  import { readChapterLead } from "../../../../core/self/index.js";
12
+ import { recurrenceOfRow } from "../../../../core/store/index.js";
12
13
  import type { MemoryRow, ReadOnlyStore } from "../../../../core/store/index.js";
14
+ import { readableRecurrence } from "../../../../core/time.js";
13
15
 
14
16
  /** Where the date shown beside a row came from. */
15
17
  export type DateFrom = "text" | "chapter" | "recorded";
@@ -30,6 +32,20 @@ export interface FeelingShown {
30
32
  readonly strength: number;
31
33
  }
32
34
 
35
+ /**
36
+ * How often a row's date comes round, as a person says it — `every May 14`,
37
+ * `every Monday` (`time#readableRecurrence`) — or null for a date that happens
38
+ * once. The same predicate the prune's `recurring` gate reads
39
+ * (`store#recurrenceOfRow`, 2026-10-09), so a row that says it repeats is one
40
+ * the prune keeps for its next occurrence.
41
+ */
42
+ export function repeatsOf(row: Pick<MemoryRow, "event_date" | "meta">): string | null {
43
+ const rule = recurrenceOfRow(row);
44
+ if (rule === null || row.event_date === null) return null;
45
+ const words = readableRecurrence(row.event_date, rule);
46
+ return words === "" ? null : words;
47
+ }
48
+
33
49
  /**
34
50
  * A JOURNAL-CHAPTER MEMORY: a `memory` row minted from a chapter of the journal
35
51
  * (`source = episode`, `meta.episodeId`). Its text is the chapter as written,
@@ -14,10 +14,11 @@ import type { DashboardSource } from "../../source.js";
14
14
  import { WITHHELD, gistOfDoc, reveal, revealHere } from "../reveal.js";
15
15
  import { archiveWords } from "./archive-words.js";
16
16
  import { fadeCurve } from "./mechanism-panel.js";
17
- import { chapterDate, feelingsShown, isChapterMemory, liftDate, stripChapterLead } from "./memory-words.js";
17
+ import { chapterDate, feelingsShown, isChapterMemory, liftDate, repeatsOf, stripChapterLead } from "./memory-words.js";
18
18
  import { readChapterLead } from "../../../../core/self/index.js";
19
19
  import type { FeelingShown } from "./memory-words.js";
20
20
  import { LOG_CEILING } from "./shared.js";
21
+ import { isDay, localClockZone, localDate } from "../../../../core/time.js";
21
22
 
22
23
  /** One step in a memory's lineage, as the card's timeline draws it. */
23
24
  export interface TimelineStep {
@@ -95,9 +96,19 @@ export interface MemoryCurve {
95
96
  readonly from: number;
96
97
  readonly to: number;
97
98
  readonly points: readonly (readonly [number, number])[];
99
+ /** The first lived day ahead on which it falls below the archive line if
100
+ * unused — the day the prune could put it away. Null for a date that still
101
+ * repeats: the prune keeps it for its next occurrence (2026-10-09). Null for
102
+ * a protected memory too: the prune never lets one go (review of #343). */
98
103
  readonly archiveDay: number | null;
99
104
  readonly archiveLine: number;
100
105
  readonly semanticFloor: number;
106
+ /** Its date still repeats: how often, as a person says it (`every May 14`,
107
+ * `repeatsOf`), else null. The card says this instead of a let-go day. */
108
+ readonly repeats: string | null;
109
+ /** Protected (`physics.protected`): the prune refuses it however faint it
110
+ * grows, so the card says that instead of a let-go day (review of #343). */
111
+ readonly protected: boolean;
101
112
  }
102
113
 
103
114
  // ─────────────────────────────────────────────────────────────────────────────
@@ -193,6 +204,16 @@ export interface MemoryDetail {
193
204
  readonly model: string | null;
194
205
  readonly eventDate: string | null;
195
206
  readonly createdAt: number | null;
207
+ /**
208
+ * The day it was written, `YYYY-MM-DD`, in the person's zone (`store.zone()`:
209
+ * the configuration's `timeZone`, else the machine's) — the local date of
210
+ * `createdAt`, else the recorded calendar day. Dated HERE, not by the
211
+ * browser, so the card agrees with every other date the dashboard prints
212
+ * (review of #335, 2026-10-09). Null when nothing dates it.
213
+ */
214
+ readonly writtenOn: string | null;
215
+ /** The clock it was written at, in the same zone and named: `17:47 MDT`. Null without `createdAt`. */
216
+ readonly writtenClock: string | null;
196
217
  /** Why it was archived, in plain words; null while it is live. */
197
218
  readonly archivedWords: string | null;
198
219
  /** Its lineage, oldest first: what it replaced or corrects, its own rewrites, what it became. */
@@ -267,6 +288,8 @@ export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
267
288
  model: null,
268
289
  eventDate: null,
269
290
  createdAt: null,
291
+ writtenOn: null,
292
+ writtenClock: null,
270
293
  archivedWords: null,
271
294
  timeline: [],
272
295
  shownText: "",
@@ -302,7 +325,20 @@ export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
302
325
  else if (physics.promotedIdentity === true) curveNote = "in the core — it doesn't fade";
303
326
  else {
304
327
  const c = fadeCurve(physics, day);
305
- curve = { day, ...c, archiveLine: TUNABLES.PHI_PRUNE, semanticFloor: TUNABLES.THETA_SEM };
328
+ // A date that still repeats is kept (the prune's `recurring` gate), and so
329
+ // is a protected memory (its `protected` gate, review of #343): neither has
330
+ // a let-go day. A put-away row is past the question.
331
+ const repeats = row === undefined || row.archived === 1 ? null : repeatsOf(row);
332
+ const kept = physics.protected === true;
333
+ curve = {
334
+ day,
335
+ ...c,
336
+ archiveDay: repeats === null && !kept ? c.archiveDay : null,
337
+ archiveLine: TUNABLES.PHI_PRUNE,
338
+ semanticFloor: TUNABLES.THETA_SEM,
339
+ repeats,
340
+ protected: kept,
341
+ };
306
342
  }
307
343
 
308
344
  const points: { role: string; id: string; text: string }[] = [];
@@ -391,12 +427,25 @@ export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
391
427
  model: row?.model ?? null,
392
428
  eventDate: row?.event_date ?? null,
393
429
  createdAt: row?.created_at ?? null,
430
+ ...writtenWhen(row?.created_at ?? null, doc.learnedOn, store.zone()),
394
431
  archivedWords: row?.archived === 1 ? archiveWords(row.archived_reason ?? null, row.superseded_by !== null) : null,
395
432
  timeline: timelineOf(src, headId, doc.meta["updates"]),
396
433
  ...cardWords(doc.body.trim(), chapter, g.confidential),
397
434
  };
398
435
  }
399
436
 
437
+ /** The card's "Written" day and the details row's clock, both in `zone` (`MemoryDetail.writtenOn`). */
438
+ export function writtenWhen(
439
+ createdAt: number | null,
440
+ learnedOn: string,
441
+ zone: string,
442
+ ): { writtenOn: string | null; writtenClock: string | null } {
443
+ if (createdAt !== null && createdAt > 0) {
444
+ return { writtenOn: localDate(createdAt, zone) || null, writtenClock: localClockZone(createdAt, zone) || null };
445
+ }
446
+ return { writtenOn: isDay(learnedOn) ? learnedOn : null, writtenClock: null };
447
+ }
448
+
400
449
  /** The lived days the log shows this memory being credited for use (`recall.credit`'s `ids`). */
401
450
  function useDaysOf(src: DashboardSource, id: string): number[] {
402
451
  const days = new Set<number>();