counterparts 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/docs/module-map.md +1 -1
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +36 -10
  5. package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
  6. package/src/adapters/claude-code/NOTES.md +131 -0
  7. package/src/adapters/claude-code/bin/hook.ts +35 -2
  8. package/src/adapters/claude-code/doctor.ts +155 -21
  9. package/src/adapters/claude-code/hooks.ts +49 -7
  10. package/src/adapters/claude-code/index.ts +11 -0
  11. package/src/adapters/claude-code/night-run.ts +133 -12
  12. package/src/adapters/claude-code/transcript.ts +268 -1
  13. package/src/adapters/cli/CONTRACT.md +5 -0
  14. package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
  15. package/src/adapters/cli/NOTES.md +111 -0
  16. package/src/adapters/cli/commands.ts +65 -14
  17. package/src/adapters/cli/dream-core.ts +57 -42
  18. package/src/adapters/cli/export.ts +320 -21
  19. package/src/adapters/cli/index.ts +1 -0
  20. package/src/adapters/cli/install.ts +39 -7
  21. package/src/adapters/cli/mechanisms.ts +7 -1
  22. package/src/adapters/cli/uninstall.ts +13 -5
  23. package/src/adapters/cli/wire.ts +189 -63
  24. package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
  25. package/src/adapters/dashboard/NOTES.md +79 -0
  26. package/src/adapters/dashboard/registries.ts +10 -2
  27. package/src/adapters/dashboard/web/README.md +19 -14
  28. package/src/adapters/dashboard/web/actions.ts +23 -1
  29. package/src/adapters/dashboard/web/flow.ts +4 -1
  30. package/src/adapters/dashboard/web/lanes.ts +3 -0
  31. package/src/adapters/dashboard/web/narrate.ts +30 -2
  32. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
  33. package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
  34. package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
  35. package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
  36. package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
  37. package/src/adapters/dashboard/web/server.ts +0 -5
  38. package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
  39. package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
  40. package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
  41. package/src/adapters/dashboard/web/views/health.ts +1 -1
  42. package/src/adapters/dashboard/web/views/search.ts +4 -45
  43. package/src/adapters/dashboard/web/views.ts +2 -2
  44. package/src/adapters/fired.ts +410 -25
  45. package/src/adapters/host-wiring.ts +300 -0
  46. package/src/adapters/lifecycle.ts +14 -0
  47. package/src/adapters/log/index.ts +2 -0
  48. package/src/adapters/mcp/CONTRACT.md +33 -3
  49. package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
  50. package/src/adapters/mcp/NOTES.md +136 -0
  51. package/src/adapters/mcp/bin/serve.ts +30 -0
  52. package/src/adapters/mcp/facts.ts +13 -1
  53. package/src/adapters/mcp/meaning.ts +208 -13
  54. package/src/adapters/mcp/server.ts +87 -15
  55. package/src/adapters/mcp/stdio.ts +3 -1
  56. package/src/adapters/mcp/stood-down.ts +51 -0
  57. package/src/adapters/mcp/tools.ts +27 -7
  58. package/src/adapters/plugin-run.sh +133 -0
  59. package/src/adapters/plugin.ts +329 -0
  60. package/src/core/associate/CONTRACT.md +2 -1
  61. package/src/core/associate/INTERFACE-GAPS.md +6 -1
  62. package/src/core/associate/NOTES.md +45 -0
  63. package/src/core/briefing.ts +12 -3
  64. package/src/core/contradictions.ts +184 -0
  65. package/src/core/counterpart.ts +451 -18
  66. package/src/core/dream/CONTRACT.md +5 -2
  67. package/src/core/dream/INTERFACE-GAPS.md +29 -6
  68. package/src/core/dream/NOTES.md +21 -0
  69. package/src/core/dream/index.ts +33 -1
  70. package/src/core/dream/reflect.ts +20 -5
  71. package/src/core/encode/INTERFACE-GAPS.md +3 -1
  72. package/src/core/fit/INTERFACE-GAPS.md +8 -2
  73. package/src/core/fit/NOTES.md +5 -2
  74. package/src/core/fit/index.ts +4 -1
  75. package/src/core/handoff/CONTRACT.md +37 -2
  76. package/src/core/handoff/INTERFACE-GAPS.md +10 -0
  77. package/src/core/handoff/NOTES.md +66 -0
  78. package/src/core/handoff/index.ts +214 -12
  79. package/src/core/mint.ts +8 -2
  80. package/src/core/physics/CONTRACT.md +11 -1
  81. package/src/core/physics/NOTES.md +30 -0
  82. package/src/core/physics/index.ts +26 -4
  83. package/src/core/prospective/CONTRACT.md +45 -6
  84. package/src/core/prospective/INTERFACE-GAPS.md +4 -0
  85. package/src/core/prospective/NOTES.md +138 -0
  86. package/src/core/prospective/derive.ts +33 -5
  87. package/src/core/prospective/index.ts +90 -5
  88. package/src/core/prospective/windows.ts +72 -1
  89. package/src/core/recall/CONTRACT.md +6 -2
  90. package/src/core/recall/INTERFACE-GAPS.md +28 -4
  91. package/src/core/recall/NOTES.md +57 -1
  92. package/src/core/recall/probe.ts +58 -0
  93. package/src/core/recall/session.ts +27 -3
  94. package/src/core/recall/time-ask.ts +116 -18
  95. package/src/core/remember/CONTRACT.md +4 -1
  96. package/src/core/remember/INTERFACE-GAPS.md +9 -1
  97. package/src/core/remember/proposals.ts +38 -5
  98. package/src/core/revision.ts +5 -0
  99. package/src/core/schemas/CONTRACT.md +13 -1
  100. package/src/core/schemas/INTERFACE-GAPS.md +20 -2
  101. package/src/core/schemas/NOTES.md +127 -0
  102. package/src/core/schemas/types.ts +2 -0
  103. package/src/core/self/CONTRACT.md +15 -4
  104. package/src/core/self/INTERFACE-GAPS.md +7 -2
  105. package/src/core/self/NOTES.md +49 -0
  106. package/src/core/self/briefing.ts +12 -2
  107. package/src/core/self/index.ts +82 -8
  108. package/src/core/self/page.ts +88 -0
  109. package/src/core/sleep/INTERFACE-GAPS.md +22 -3
  110. package/src/core/sleep/NOTES.md +11 -0
  111. package/src/core/sleep/prune.ts +6 -2
  112. package/src/core/store/NOTES.md +14 -0
  113. package/src/core/store/index.ts +107 -0
  114. package/src/core/time.ts +152 -0
  115. package/tools/install-loop/run.sh +48 -12
  116. package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
@@ -51,7 +51,7 @@
51
51
  * a fortnight of holidays is not a fortnight of work. An expired handoff stops
52
52
  * being shown and stops being written over: the row is simply left to the prune.
53
53
  */
54
- import type { ProseDoc, Store } from "../store/index.js";
54
+ import type { MemoryStatus, ProseDoc, Store } from "../store/index.js";
55
55
  import { isKnownSession, isModelId } from "../types.js";
56
56
 
57
57
  /** The `meta.role` that makes a schema row a handoff. One per scope and session. */
@@ -110,11 +110,13 @@ export const HANDOFF_EXCERPT_BYTES = 160;
110
110
  * 1,431 since the newest says how far its work since is written up
111
111
  * (2026-09-30), and 1,646 since each says why it may be out of date — an
112
112
  * older release wrote it, or a newer chapter was written here (2026-10-01).
113
+ * 1,963 since a "since" line can follow it (2026-10-09): three plans at the
114
+ * title cap and a count, 317 bytes on the widest block (1,646).
113
115
  * In practice the share rule binds first: at the 9,000 bytes the owner's hosts
114
116
  * report, no reserve can pass 1,125, so a block that wide is carried with two
115
117
  * shown rather than three.
116
118
  */
117
- export const HANDOFF_RESERVE_MAX_BYTES = 1646;
119
+ export const HANDOFF_RESERVE_MAX_BYTES = 1963;
118
120
 
119
121
  /**
120
122
  * Slack on top of the block that actually exists, so a reserve taken at one
@@ -986,6 +988,10 @@ export function pointerBlockMany(
986
988
  * rung is for the one-boundary lag (NOTES §2): a directory's first second
987
989
  * author appears at a boundary whose reserve was sized to one handoff, and a
988
990
  * shorter pointer that fits beats a fuller one dropped whole.
991
+ *
992
+ * With `plans` (2026-10-09), each of those rungs comes first with the "since"
993
+ * line under it (`sinceLine`), and then the rungs above, unchanged. A rung's
994
+ * `plans` is the ids its line names — none on a rung without one.
989
995
  */
990
996
  export function pointerLadder(
991
997
  hs: readonly Handoff[],
@@ -994,22 +1000,114 @@ export function pointerLadder(
994
1000
  readonly since?: readonly (PointerSince | null)[];
995
1001
  readonly reader?: string | null;
996
1002
  readonly lifeDays?: number;
1003
+ /** What was planned here since the newest (`Handoffs#plansSince`). */
1004
+ readonly plans?: PlansSince | null;
997
1005
  } = {},
998
- ): { block: string; shown: readonly Handoff[] }[] {
1006
+ ): { block: string; shown: readonly Handoff[]; plans: readonly string[] }[] {
999
1007
  const lifeDays = opts.lifeDays ?? HANDOFF_LIFE_DAYS;
1000
1008
  const live = hs.filter((h) => !expired(h, day, lifeDays));
1001
1009
  const first = live[0];
1002
1010
  if (first === undefined) return [];
1003
1011
  const single = pointerBlock(first, day, lifeDays, opts.since?.[0] ?? null, opts.reader ?? null);
1004
- const out: { block: string; shown: readonly Handoff[] }[] = [];
1012
+ const out: { block: string; shown: readonly Handoff[]; several: boolean }[] = [];
1005
1013
  if (live.length > 1) {
1006
1014
  for (let k = Math.min(HANDOFF_WAKE_SHOWN, live.length); k >= 1; k--) {
1007
1015
  const block = pointerBlockMany(live, day, { ...opts, shown: k });
1008
- if (block !== null) out.push({ block, shown: live.slice(0, k) });
1016
+ if (block !== null) out.push({ block, shown: live.slice(0, k), several: true });
1009
1017
  }
1010
1018
  }
1011
- if (single !== null) out.push({ block: single, shown: [first] });
1012
- return out;
1019
+ if (single !== null) out.push({ block: single, shown: [first], several: false });
1020
+ // SINCE THIS HANDOFF (2026-10-09): every rung once WITH the line, widest
1021
+ // first, then every rung as it was — so a ceiling with no room for the line
1022
+ // carries today's block byte for byte. The line is tried before an older
1023
+ // handoff is kept in full: what was planned here after the newest handoff
1024
+ // is newer than any of them.
1025
+ const plans = opts.plans ?? null;
1026
+ const listed = (plans?.items ?? []).slice(0, SINCE_SHOWN).map((p) => p.id);
1027
+ const withPlans = out.flatMap((rung) => {
1028
+ const line = plans === null ? null : sinceLine(plans, rung.several);
1029
+ return line === null ? [] : [{ block: `${rung.block}\n${line}`, shown: rung.shown, plans: listed }];
1030
+ });
1031
+ return [...withPlans, ...out.map((rung) => ({ block: rung.block, shown: rung.shown, plans: [] as readonly string[] }))];
1032
+ }
1033
+
1034
+ // ── what was planned here since (2026-10-09) ────────────────────────────────
1035
+
1036
+ /**
1037
+ * THE STATUSES THAT READ AS A PLAN OR A NEXT STEP — the v12 field the writer
1038
+ * fills (`store/index.ts#STATUSES`): `planned` (decided, not yet done),
1039
+ * `proposed` (put forward, not decided) and `asked` (a question or request
1040
+ * still open). Not `done`, and not a memory with no status.
1041
+ */
1042
+ export const PLAN_STATUSES: readonly MemoryStatus[] = ["planned", "proposed", "asked"];
1043
+
1044
+ /** How many the "since" line names, newest first; the rest are a count. */
1045
+ export const SINCE_SHOWN = 3;
1046
+
1047
+ /** A title's cap in the line, in bytes. The id is the door to the whole memory. */
1048
+ export const SINCE_TITLE_BYTES = 60;
1049
+
1050
+ /**
1051
+ * WHAT ITS OWN SESSION WROTE THIS SOON AFTER THE HANDOFF IS PART OF THE SAME
1052
+ * ANSWER, not news: the `session_end` call writes its handoff first and its
1053
+ * memories straight after (`mcp/server.ts#sessionEndTool`), and an end-of-
1054
+ * stretch answer may add a note or a chapter in the same turn. Five minutes,
1055
+ * the grace a chapter's span gives the same answer
1056
+ * (`self/chapter-address.ts#CHAPTER_MOMENT_GRACE_MS`). A working default.
1057
+ */
1058
+ export const SINCE_SAME_ANSWER_MS = 5 * 60_000;
1059
+
1060
+ /** How many candidates one read takes, newest first (`Store#planCandidates`). */
1061
+ export const SINCE_READ = 30;
1062
+
1063
+ /** One memory the "since" line names. */
1064
+ export interface PlanSince {
1065
+ readonly id: string;
1066
+ /** Its title, or its first sentence when it has none, cut to `SINCE_TITLE_BYTES`. */
1067
+ readonly title: string;
1068
+ /** What kind of thing it is, as the line prints it (`planWord`). */
1069
+ readonly word: string;
1070
+ }
1071
+
1072
+ /** What was planned here since a handoff: the newest first, and how many more. */
1073
+ export interface PlansSince {
1074
+ readonly items: readonly PlanSince[];
1075
+ readonly more: number;
1076
+ }
1077
+
1078
+ /**
1079
+ * IS THIS A PLAN OR A NEXT STEP, and the word the line prints for it: its
1080
+ * status when that is one of `PLAN_STATUSES`, else "open" for a memory still
1081
+ * flagged `unresolved` (the word the wake's "Still open:" lane uses). Null
1082
+ * for anything else. Pure.
1083
+ */
1084
+ export function planWord(status: string | null | undefined, unresolved: boolean): string | null {
1085
+ if (typeof status === "string" && (PLAN_STATUSES as readonly string[]).includes(status)) return status;
1086
+ return unresolved ? "open" : null;
1087
+ }
1088
+
1089
+ /**
1090
+ * THE LINE UNDER THE POINTER (2026-10-09): what this directory's sessions
1091
+ * wrote after the newest handoff that reads as a plan or a next step — up to
1092
+ * `SINCE_SHOWN` by title, word and id, newest first, the rest by count.
1093
+ * `several` says the block shows more than one handoff, so the line says
1094
+ * which one it counts from. Flattened, no bullet: the pointer is furniture.
1095
+ * Null with nothing to name. Pure.
1096
+ */
1097
+ export function sinceLine(plans: PlansSince, several: boolean): string | null {
1098
+ const shown = plans.items.slice(0, SINCE_SHOWN);
1099
+ if (shown.length === 0) return null;
1100
+ const more = plans.more + plans.items.length - shown.length;
1101
+ const lead = several ? "Since the newest handoff here:" : "Since this handoff:";
1102
+ const list = shown.map((p) => `${p.title} (${p.word}, ${p.id})`).join("; ");
1103
+ return flatten(`${lead} ${list}${more > 0 ? `; and ${String(more)} more` : ""}.`);
1104
+ }
1105
+
1106
+ /** `/a/b/` and `/a/b` name one directory, as `self/work.ts` reads them. */
1107
+ function scopeSpellings(scope: string): string[] {
1108
+ const trimmed = scope.trim();
1109
+ const bare = trimmed.replace(/\/+$/, "");
1110
+ return bare.length > 0 && bare !== trimmed ? [trimmed, bare] : [trimmed];
1013
1111
  }
1014
1112
 
1015
1113
  // ── the module ──────────────────────────────────────────────────────────────
@@ -1025,6 +1123,25 @@ export interface HandoffsOptions {
1025
1123
  data?: Record<string, string | number | boolean | null>;
1026
1124
  }) => void;
1027
1125
  readonly now?: () => number;
1126
+ /**
1127
+ * Whether a confidential memory may be named in the "since" line — the
1128
+ * owner's own session, as a confidential chapter is "last here" to the
1129
+ * owner only (2026-10-09).
1130
+ */
1131
+ readonly owner?: boolean;
1132
+ /**
1133
+ * The memories a later one settled over (`self/index.ts#settledOver`), which
1134
+ * no wake line shows; asked only when there is something to name. Passed in
1135
+ * by the root, because `handoff/` depends on `store/` and nothing else.
1136
+ */
1137
+ readonly settled?: () => ReadonlySet<string>;
1138
+ /**
1139
+ * The memories the published wake already lists under "Still open:"
1140
+ * (`self/index.ts#threadsShown`), which the "since" line leaves to that
1141
+ * lane rather than name twice (review of #332). Asked only when there is
1142
+ * something to name; passed in by the root, as `settled` is.
1143
+ */
1144
+ readonly listed?: () => ReadonlySet<string>;
1028
1145
  }
1029
1146
 
1030
1147
  export interface WriteInput {
@@ -1045,6 +1162,9 @@ export class Handoffs {
1045
1162
  private readonly observer: boolean;
1046
1163
  private readonly onEvent: HandoffsOptions["onEvent"];
1047
1164
  private readonly nowFn: () => number;
1165
+ private readonly owner: boolean;
1166
+ private readonly settled: (() => ReadonlySet<string>) | undefined;
1167
+ private readonly listed: (() => ReadonlySet<string>) | undefined;
1048
1168
 
1049
1169
  constructor(opts: HandoffsOptions) {
1050
1170
  this.store = opts.store;
@@ -1052,6 +1172,9 @@ export class Handoffs {
1052
1172
  this.observer = opts.observer === true;
1053
1173
  this.onEvent = opts.onEvent;
1054
1174
  this.nowFn = opts.now ?? Date.now;
1175
+ this.owner = opts.owner === true;
1176
+ this.settled = opts.settled;
1177
+ this.listed = opts.listed;
1055
1178
  }
1056
1179
 
1057
1180
  private emit(
@@ -1132,7 +1255,10 @@ export class Handoffs {
1132
1255
  // Sized to the widest "how current" words the delivery can add, which
1133
1256
  // it computes only then — on the newest in full, the rest a stamp.
1134
1257
  const since = hs.map((_, i) => (i === 0 ? WIDEST_POINTER_SINCE : WIDEST_OLDER_SINCE));
1135
- const rungs = pointerLadder(hs, d, { since }).map((rung) => byteLengthOf(rung.block));
1258
+ // What was planned here since the newest, as it stands now (2026-10-09):
1259
+ // sized to the line that exists, as the rest of the block is.
1260
+ const plans = hs[0] === undefined ? null : this.plansSince(scope, hs[0]);
1261
+ const rungs = pointerLadder(hs, d, { since, plans }).map((rung) => byteLengthOf(rung.block));
1136
1262
  if (rungs.length > 0) out.set(scope, rungs);
1137
1263
  }
1138
1264
  return out;
@@ -1343,7 +1469,7 @@ export class Handoffs {
1343
1469
  day?: number,
1344
1470
  since?: (h: Handoff, newest: boolean) => PointerSince | null,
1345
1471
  reader?: string | null,
1346
- ): { block: string; handoff: Handoff; shown: readonly Handoff[]; live: number } | null {
1472
+ ): { block: string; handoff: Handoff; shown: readonly Handoff[]; live: number; plans: readonly string[] } | null {
1347
1473
  return this.pointerChoices(scope, day, since, reader)[0] ?? null;
1348
1474
  }
1349
1475
 
@@ -1360,7 +1486,7 @@ export class Handoffs {
1360
1486
  day?: number,
1361
1487
  since?: (h: Handoff, newest: boolean) => PointerSince | null,
1362
1488
  reader?: string | null,
1363
- ): { block: string; handoff: Handoff; shown: readonly Handoff[]; live: number }[] {
1489
+ ): { block: string; handoff: Handoff; shown: readonly Handoff[]; live: number; plans: readonly string[] }[] {
1364
1490
  const d = day ?? this.store.livedDay();
1365
1491
  const hs = this.readAll(scope, d);
1366
1492
  const first = hs[0];
@@ -1372,14 +1498,87 @@ export class Handoffs {
1372
1498
  return null;
1373
1499
  }
1374
1500
  });
1375
- return pointerLadder(hs, d, { since: current, reader: reader ?? null }).map((rung) => ({
1501
+ const plans = this.plansSince(scope, first);
1502
+ return pointerLadder(hs, d, { since: current, reader: reader ?? null, plans }).map((rung) => ({
1376
1503
  block: rung.block,
1377
1504
  handoff: first,
1378
1505
  shown: rung.shown,
1379
1506
  live: hs.length,
1507
+ plans: rung.plans,
1380
1508
  }));
1381
1509
  }
1382
1510
 
1511
+ /**
1512
+ * WHAT WAS PLANNED HERE SINCE THIS HANDOFF (2026-10-09): the memories this
1513
+ * directory's sessions wrote by hand after its words were written whose
1514
+ * status is a plan or a next step (`PLAN_STATUSES`) or that are still
1515
+ * flagged `unresolved` — newest first, `SINCE_SHOWN` of them named and the
1516
+ * rest counted. A session that wrote a handoff and later changed the plan
1517
+ * in a note, without rewriting the handoff, left the newer memory quiet:
1518
+ * the pointer was the only place a waking session was told to resume from.
1519
+ *
1520
+ * Its own session's memories count, except what it wrote within
1521
+ * `SINCE_SAME_ANSWER_MS` of the handoff, which is the same answer. Left
1522
+ * out: what a later memory settled over, what the published wake already
1523
+ * lists under "Still open:" (`HandoffsOptions.listed`), a journal chapter's
1524
+ * copy, and a confidential memory unless the owner's (`HandoffsOptions.owner`). The
1525
+ * columns are read first (`Store#planCandidates`), then the prose of what
1526
+ * comes back. Never throws: a store that will not answer names nothing.
1527
+ */
1528
+ plansSince(scope: string, h: Handoff): PlansSince {
1529
+ const none: PlansSince = { items: [], more: 0 };
1530
+ try {
1531
+ const after = this.writtenAt(h);
1532
+ if (after === null) return none;
1533
+ const ids = this.store.planCandidates({
1534
+ scopes: scopeSpellings(scope),
1535
+ after,
1536
+ statuses: PLAN_STATUSES,
1537
+ limit: SINCE_READ,
1538
+ confidential: this.owner,
1539
+ });
1540
+ if (ids.length === 0) return none;
1541
+ const ask = (f: (() => ReadonlySet<string>) | undefined): ReadonlySet<string> => {
1542
+ try {
1543
+ return f?.() ?? new Set();
1544
+ } catch {
1545
+ return new Set();
1546
+ }
1547
+ };
1548
+ const settled = ask(this.settled);
1549
+ // ONE PLACE FOR AN OPEN QUESTION (review of #332): one the published
1550
+ // wake already lists under "Still open:" is left to that lane. One it
1551
+ // does not — opened since the last boundary, or past the lane's cap,
1552
+ // which takes the oldest first — is named here.
1553
+ const listed = ask(this.listed);
1554
+ const found: PlanSince[] = [];
1555
+ for (const id of ids) {
1556
+ if (settled.has(id) || listed.has(id)) continue;
1557
+ const row = this.store.row(id);
1558
+ if (row === undefined) continue;
1559
+ if (h.session !== null && row.origin_session === h.session && (row.created_at ?? 0) - after <= SINCE_SAME_ANSWER_MS) {
1560
+ continue;
1561
+ }
1562
+ let doc: ProseDoc;
1563
+ try {
1564
+ doc = this.store.readProse(id);
1565
+ } catch {
1566
+ continue;
1567
+ }
1568
+ if (typeof doc.meta["episodeId"] === "string") continue;
1569
+ const word = planWord(row.status ?? null, doc.meta["unresolved"] === true);
1570
+ if (word === null) continue;
1571
+ const title = flatten(doc.title ?? "");
1572
+ const text = excerpt(title.length > 0 ? title : doc.body, SINCE_TITLE_BYTES);
1573
+ if (text.length === 0) continue;
1574
+ found.push({ id, title: text, word });
1575
+ }
1576
+ return { items: found.slice(0, SINCE_SHOWN), more: Math.max(0, found.length - SINCE_SHOWN) };
1577
+ } catch {
1578
+ return none;
1579
+ }
1580
+ }
1581
+
1383
1582
  /**
1384
1583
  * WHEN THIS HANDOFF'S WORDS WERE WRITTEN, epoch ms: its newest
1385
1584
  * `handoff.written` row (the log keeps ~90 lived days; a pointer lives 14).
@@ -1411,7 +1610,7 @@ export class Handoffs {
1411
1610
  * the ROW's id and the lived day — never the directory, which is a path
1412
1611
  * (§5 G10).
1413
1612
  */
1414
- noteShown(h: Handoff, opts: { bytes: number; session?: string | null; day?: number; among?: number }): void {
1613
+ noteShown(h: Handoff, opts: { bytes: number; session?: string | null; day?: number; among?: number; plans?: number }): void {
1415
1614
  if (this.observer) {
1416
1615
  this.emit("handoff.observer.standdown", undefined, { site: "noteShown" });
1417
1616
  return;
@@ -1432,6 +1631,9 @@ export class Handoffs {
1432
1631
  // How many live handoffs the directory held when this one was shown
1433
1632
  // (2026-09-30) — absent when it was the only one.
1434
1633
  ...(opts.among === undefined || opts.among <= 1 ? {} : { among: opts.among }),
1634
+ // How many memories the "since" line named beside it (2026-10-09) —
1635
+ // absent when it named none.
1636
+ ...(opts.plans === undefined || opts.plans <= 0 ? {} : { plans: opts.plans }),
1435
1637
  },
1436
1638
  });
1437
1639
  } catch {
package/src/core/mint.ts CHANGED
@@ -49,9 +49,9 @@
49
49
  * resolution, upstream, and this file does not write a second one.
50
50
  */
51
51
  import { TUNABLES as PHYSICS, clampSalienceAtSeam } from "./physics/index.js";
52
- import { CUE_MODE_META, DATE_FROM_META } from "./prospective/index.js";
52
+ import { CUE_MODE_META, DATE_FROM_META, RECURRING_META } from "./prospective/index.js";
53
53
  import type { Proposal } from "./remember/index.js";
54
- import { localDate } from "./time.js";
54
+ import { isDay, isRecurrence, localDate } from "./time.js";
55
55
  import type { Store } from "./store/index.js";
56
56
  import { SECOND_HAND_META_KEY, WRITTEN_UP_BY_META_KEY } from "./types.js";
57
57
  import type { Band, Salience } from "./types.js";
@@ -196,6 +196,12 @@ export function mintProposal(store: Store, proposal: Proposal, opts: MintOptions
196
196
  // PLAIN OR QUIET rides the meta bag beside its date (2026-09-26, no schema
197
197
  // bump), under the key its one reader owns.
198
198
  if (proposal.eventDate !== null && proposal.remind !== null) meta[CUE_MODE_META] = proposal.remind;
199
+ // HOW OFTEN IT COMES ROUND (2026-10-09), in the same bag for the same
200
+ // reason: no schema bump. Only beside a day — intake refuses it on anything
201
+ // else, and a carried one that no longer fits was dropped by the carry.
202
+ if (proposal.eventDate !== null && isDay(proposal.eventDate) && isRecurrence(proposal.recurring)) {
203
+ meta[RECURRING_META] = proposal.recurring;
204
+ }
199
205
  // The memory a revision took its reminder from (`Counterpart#carryReminder`):
200
206
  // an id, so what was already said for the same window still counts.
201
207
  if (proposal.reminderFrom !== undefined) meta[DATE_FROM_META] = proposal.reminderFrom;
@@ -324,8 +324,18 @@ PRUNE(m,d) iff strength(m,d) < φ = 0.02 # TUNABLE
324
324
  and (d − last_used_day(m)) ≥ D_floor = 90 # TUNABLE, lived days
325
325
  and band(m) == episodic and not protected(m)
326
326
  and m is neither successor nor predecessor in a live revision chain
327
+ and m's reminder date does not still repeat # 2026-10-09
327
328
  ```
328
329
 
330
+ The sixth gate (`recurring`, the owner's decision of 2026-10-09, held lightly): a memory
331
+ whose `event_date` repeats (`meta.recurring`, prospective §3) is refused by name, as a
332
+ protected one is. Each delivered occurrence counts as a use, which carries a daily,
333
+ weekly or monthly repeat; a yearly one is used once a year, and no single use outlasts
334
+ 365 lived days at an ordinary salience. Only the prune: it still decays, its band and
335
+ strength read as before. The caller supplies it (`sleep/prune.ts`, from the row's meta).
336
+ It is an exemption from the floor, so the verdict names it only where the first three
337
+ conditions hold (review of #341); a repeat above the floor is refused `above-floor` alone.
338
+
329
339
  A prune is recorded — counts, kind, dates, never a body and never a content hash (scar
330
340
  §2.20) — and is the only physics-driven removal. Everything else merely fades: a
331
341
  low-strength memory is still present and still retrievable by a strong enough cue.
@@ -355,7 +365,7 @@ low-strength memory is still present and still retrievable by a strong enough cu
355
365
  store fact the caller supplies, the refusal is named
356
366
  (`revision-successor-never-merged`), and it is checked before hash and cosine.
357
367
  9. **[M]** Superseded versions stay resolvable for `H` lived days; nothing here deletes one.
358
- 10. **[M]** Prune is gated on all five conditions and is recorded; no model-reachable caller
368
+ 10. **[M]** Prune is gated on all six conditions and is recorded; no model-reachable caller
359
369
  can invoke it.
360
370
  11. **[A]** The per-kind tables are v1's calibration, not law. They ship with a recorded
361
371
  calibration and a fixture-bounded window, or disabled (scar §2.8).
@@ -471,3 +471,33 @@ and every other reader go through `strength()` and see it without change.
471
471
  (`dream/reflect.ts`), and doctor counts the memories on this lane ("Recognition"). Not built:
472
472
  anything reading recognition for the self page (arcs from uneasy to calm, moments of
473
473
  recognition) — that is the page's design note, not a mechanism yet.
474
+
475
+ ## 2026-10-09 — a repeating date is not pruned (the sixth gate)
476
+
477
+ The owner's decision on #339's review, held lightly: each occurrence of a repeating
478
+ reminder that is actually said or surfaced counts as a use (`Counterpart#creditOccurrence`
479
+ → `store.reinforce`, the `surfaced` tier, once per occurrence), and if that cannot carry a
480
+ yearly one across its gap, the prune refuses a live repeat by name. It cannot: one
481
+ surfaced use multiplies S by `1 + 0.5 ln 1.25` ≈ 1.11, so a default-claim memory is back
482
+ under `PHI_PRUNE` in about 170 lived days (a fact) to 270 (a person, with the emotion
483
+ lift), and past the 90-day dwell by then. Measured through the hooks: without the gate,
484
+ `test/recurring-reinforce.test.ts`'s yearly birthday was let go 263 lived days after its
485
+ first May 14. So `pruneVerdict` takes `ctx.recurring` and blocks with `recurring`, the
486
+ way `protected` blocks; `sleep/prune.ts` reads it off the row (`store#recurrenceOfRow`,
487
+ the predicate `recurringMemories` uses). Nothing else moves here: decay, band and strength
488
+ are unchanged, so the memories view still shows a repeat as fading between its dates.
489
+ (Prospective, in the review of #341, stopped refusing a live repeat `faded`, so a QUIET
490
+ yearly that faded by its next date is still cued on it — prospective NOTES §16.) The
491
+ entity-card fade (`schemas/`) and the memories view's `letGoDay` never pass it, so the
492
+ view's "fading" and let-go day for a repeat are what the floor alone would do.
493
+ `fired.ts` counts it with `protected` and `in-live-revision-chain` as a real refusal —
494
+ and so `pruneVerdict` names it only where the floor would otherwise have let the memory
495
+ go (review of #341). It is an exemption from the floor, not a standing rule: named on
496
+ every live repeat every night, a strong daily pill reminder read as a refusal and turned
497
+ the fired view's prune row BLOCKED on a store where nothing was wrong.
498
+
499
+ Why `surfaced` and not `referenced`: an occurrence delivered is a showing, and nothing
500
+ says the reply used it; and `creditReturn` refuses `not-referenced`, so a schedule earns
501
+ no return and a daily `self` reminder cannot walk the slow core lane on the calendar
502
+ alone. The rep arm still climbs where the kind has one (`uses` +0.25 a day: a daily
503
+ `fact` sits at the 0.5 cap after about 17 days) — rehearsal working, not a side effect.
@@ -1556,7 +1556,9 @@ export type PruneReason =
1556
1556
  | "dwell-too-short"
1557
1557
  | "band-not-episodic"
1558
1558
  | "protected"
1559
- | "in-live-revision-chain";
1559
+ | "in-live-revision-chain"
1560
+ /** Its reminder date still repeats (`meta.recurring`, 2026-10-09): see `pruneVerdict`. */
1561
+ | "recurring";
1560
1562
 
1561
1563
  /** Counts, kind, dates. NEVER a body and NEVER a content hash (scar §2.20). */
1562
1564
  export interface PruneRecord {
@@ -1573,7 +1575,8 @@ export interface PruneRecord {
1573
1575
  export interface PruneVerdict {
1574
1576
  prune: boolean;
1575
1577
  reason: PruneReason;
1576
- /** Every failing gate, not just the first — all five are named. */
1578
+ /** Every failing gate, not just the first — all six are named; `recurring`
1579
+ * only where the floor alone would have let the memory go. */
1577
1580
  blockedBy: PruneReason[];
1578
1581
  strength: number;
1579
1582
  band: Band;
@@ -1582,15 +1585,26 @@ export interface PruneVerdict {
1582
1585
  }
1583
1586
 
1584
1587
  /**
1585
- * The ONLY physics-driven removal (§5.8), gated on all five conditions. No
1588
+ * The ONLY physics-driven removal (§5.8), gated on all six conditions. No
1586
1589
  * model, on any path, holds delete power — this returns a verdict and a record;
1587
1590
  * it deletes nothing itself. Everything else merely fades: a low-strength memory
1588
1591
  * is still present and still retrievable by a strong enough cue.
1592
+ *
1593
+ * `ctx.recurring` (2026-10-09, the owner's decision, held lightly): the memory's
1594
+ * reminder date still repeats. Each occurrence it is told or surfaced on counts
1595
+ * as a use (`Counterpart#creditOccurrence`), which carries a daily, weekly or
1596
+ * monthly repeat; a yearly one is used once a year, and no single use outlasts
1597
+ * 365 lived days at an ordinary salience. So a live repeat is refused here by
1598
+ * name, as `protected` is — but only where the floor would otherwise have let
1599
+ * it go, since it is an exemption from the floor and not a standing rule (review
1600
+ * of #341). Only the prune: it still fades, its band and strength read as
1601
+ * before. Prospective does not refuse a live repeat `faded` (review of #341,
1602
+ * `prospective/derive.ts`), so each occurrence is still delivered.
1589
1603
  */
1590
1604
  export function pruneVerdict(
1591
1605
  m: MemoryPhysics,
1592
1606
  d: number,
1593
- ctx: { inLiveRevisionChain: boolean },
1607
+ ctx: { inLiveRevisionChain: boolean; recurring?: boolean },
1594
1608
  shape: DecayShape = TUNABLES.DECAY_SHAPE,
1595
1609
  ): PruneVerdict {
1596
1610
  const s = strength(m, d, shape);
@@ -1600,8 +1614,16 @@ export function pruneVerdict(
1600
1614
  if (s >= TUNABLES.PHI_PRUNE) blockedBy.push("above-floor");
1601
1615
  if (dwellDays < TUNABLES.D_FLOOR_DAYS) blockedBy.push("dwell-too-short");
1602
1616
  if (b !== "episodic") blockedBy.push("band-not-episodic");
1617
+ // The three floor conditions above are arithmetic ("not yet"); the rest are
1618
+ // named rules.
1619
+ const floorLetsGo = blockedBy.length === 0;
1603
1620
  if (m.protected) blockedBy.push("protected");
1604
1621
  if (ctx.inLiveRevisionChain) blockedBy.push("in-live-revision-chain");
1622
+ // An exemption FROM THE FLOOR, so named only where the floor would have let
1623
+ // the memory go (review of #341): a repeat well above it is held by
1624
+ // `above-floor` and nothing else, and naming `recurring` on every live repeat
1625
+ // every night read as a refusal in the fired view's prune row.
1626
+ if (ctx.recurring === true && floorLetsGo) blockedBy.push("recurring");
1605
1627
  const prune = blockedBy.length === 0;
1606
1628
  return {
1607
1629
  prune,
@@ -37,6 +37,35 @@ clothes. **Hold debts, lose deadlines.**
37
37
  or range's last day) it leaves the wake's horizon lane for the rest of its grace
38
38
  (2026-09-29): it was said, and "Arriving:" would say it again as still to come. It
39
39
  still arrives as a cue, so recall still finds it.
40
+ - **A date can repeat, by the owner's design (2026-10-09, a working default, held
41
+ lightly).** A dated memory may carry `recurring: daily | weekly | monthly | yearly`,
42
+ anchored on its event date and kept in its meta beside `remind` (no schema bump): a
43
+ birthday stored as `1990-05-14` with `yearly` comes back every May 14. Each
44
+ OCCURRENCE is its own window, keyed by its own date (`d:2027-05-14`), so everything
45
+ above that is per window — the fire cap, once per lived day, the plain beat, the
46
+ referenced stop, and what a revision's `lineage` counts — is per occurrence: told once
47
+ each May 14, never once ever, never twice. Two occurrences are never open together: an
48
+ occurrence's window opens no earlier than the day after the last one and closes the day
49
+ before the next one opens (the coming lead wins over the last grace), so a daily date's
50
+ window is its day and a weekly one runs from three days before to three days after.
51
+ A daily one takes no wake line (review of #339): it is every day, not arriving, and a
52
+ wake rendered the evening before would date it yesterday. Only a DAY repeats; a month, a range or a year with `recurring` is refused at the door.
53
+ **A repeat is kept alive by coming round** (owner decision 2026-10-09, held lightly):
54
+ the first DELIVERY of each occurrence — a quiet fire the gate admitted, or a plain line
55
+ the host claimed — counts as one use of the memory (`surfaced`, no return), credited by
56
+ the composition root through the store's reinforce seam; this module answers only
57
+ whether the occurrence is still undelivered (`occurrenceUndelivered`). Never for a
58
+ one-off date or a dropped repeat. And physics' prune refuses a live repeat by name
59
+ (`recurring`), because one use a year does not outlast a yearly gap. Fading is
60
+ unchanged for recall and display, but **a live repeat is not refused `faded`** (review
61
+ of #341, the one carve-out from G10 below): a quiet yearly at the default salience has
62
+ faded by its second date, and "so they stay alive" means each occurrence is delivered by
63
+ its own remind rules (NOTES §16).
64
+ Two calendar rules, counted from the anchor every time so nothing drifts: **monthly on
65
+ the 29th, 30th or 31st falls on the last day of a month too short to have it** (Jan 31
66
+ → Feb 28, or 29 → Mar 31 → Apr 30), and **yearly on Feb 29 falls on Feb 28 in a common
67
+ year**. Out, loose first: every other week, "the first Monday", and anything finer
68
+ than a day.
40
69
  - **Prospectivity is DERIVED, never stored.** [v1] §12 G2 — eligibility is a predicate over
41
70
  the event date, the encode date, salience, and flags, so the property expires by itself
42
71
  when the window passes: no cleanup pass, no second source of truth, nothing for decay to
@@ -52,8 +81,8 @@ clothes. **Hold debts, lose deadlines.**
52
81
  **An explicit date is its own importance signal** (owner decision 2026-09-26, a working
53
82
  default): a memory whose author wrote its `eventDate` is exempt from the salience floor,
54
83
  which now gates only a date a caller extracted. Decay is not exempted — a dated memory
55
- faded to `FADED_STRENGTH` refuses as `faded` (G10) — and archived, skill and journal
56
- still refuse.
84
+ faded to `FADED_STRENGTH` refuses as `faded` (G10), unless its date still repeats (§3) —
85
+ and archived, skill and journal still refuse.
57
86
  - **Precision is carried by the date's own format**, never rounded, and the ramp differs by
58
87
  precision — a stated month *means* early month more than the 29th. [v1] §12 G4. Since
59
88
  2026-09-26 there are four shapes (`core/time.ts`): a day, a month, a year (no window), and
@@ -77,7 +106,9 @@ clothes. **Hold debts, lose deadlines.**
77
106
  nothing to the old one's spent budget. [v1] §12 G9.
78
107
  - **No decay exemption before arrival.** [v1] §12 G10 — a future-dated memory that decays
79
108
  into insignificance before its window was an occasion that didn't matter; forgetting it
80
- is memory working.
109
+ is memory working. One carve-out (review of #341, 2026-10-09): a date that still
110
+ REPEATS is not refused `faded` — the author asked for it to come round, and the owner
111
+ decided repeats stay alive (§3).
81
112
  - **Firing state is not canonical memory**, and the write budget is set by that cost:
82
113
  losing it risks one extra polite mention, never a memory, so contended writers skip the
83
114
  update loudly rather than stall a host-facing path. [v1] §12 G12.
@@ -94,8 +125,11 @@ clothes. **Hold debts, lose deadlines.**
94
125
  three unsynchronized writers — a hook, a pre-spawn boundary call, and a lock-holding
95
126
  horizon computation — each serializing the whole map, so a stale writer clobbered
96
127
  unrelated entries too (scar §2.1). Transactions close the class.
97
- - **Recurrence stays absent.** [v1's recorded punt, kept] Annual re-arm is scheduling
98
- physics, and scheduling physics is where task-queue behavior creeps back in.
128
+ - **Recurrence was absent until 2026-10-09.** [v1's recorded punt, kept until then]
129
+ "Annual re-arm is scheduling physics, and scheduling physics is where task-queue
130
+ behavior creeps back in." The owner lifted it (§3): a repeating date re-arms nothing
131
+ and stores nothing new — each occurrence is DERIVED from the anchor at read time, under
132
+ every brake a one-off date has. The risk the punt named is still the one to watch.
99
133
  - **v1's knob set is not inherited as defaults.** Salience floor, lead days, grace days, cue
100
134
  strength, fires per window, horizon lines per wake: each ships with a recorded
101
135
  calibration and a fixture-bounded window, or ships disabled (scar §2.8). v1's values are
@@ -114,7 +148,9 @@ session's affect summary; the observer predicate.
114
148
  tasks"* (day-dated items only, since 2026-09-26), and/or a temporal cue fed into the
115
149
  ordinary turn-time pass; for a PLAIN item, a claimed record the host turns into one line on
116
150
  its day (§3's named exception) — records, never words; firing-state transitions;
117
- telemetry by reference.
151
+ telemetry by reference; and for a repeating date, whether an occurrence is still
152
+ undelivered, which the caller turns into one credited use (§3) — this module writes no
153
+ physics.
118
154
 
119
155
  **Guarantees** — **[M]** mechanized, **[A]** advisory:
120
156
 
@@ -167,3 +203,6 @@ admission criterion, with a named negative example) · **§2.17** (exit paths ar
167
203
  4. **Is "plain" the right amount of loud?** (2026-09-26.) Once on the day, twice for a
168
204
  month or range, only on the stated span — no lead-day warning, no nag when the day is
169
205
  missed. The owner's first weeks of use answer it; nothing here measured it.
206
+ 5. **What should repeat beyond a day?** (2026-10-09.) "Every October" (a month, yearly),
207
+ "hourly", every other week, "the first Monday" — each left out, loose first, until a
208
+ real use asks for one.
@@ -124,6 +124,10 @@ Neither is urgent: losing this costs analytics, never a brake.
124
124
 
125
125
  ## 6. The observer predicate lives in `store/`
126
126
 
127
+ **Closed 2026-08-25 (noted 2026-10-09)** — the predicate lives in `src/core/observer.ts`
128
+ (hoisted in the wave-3 seam pass, `d88f957`); the store uses it, and this module still
129
+ reads `store.observer`, as below. Associate §8 closed the same way.
130
+
127
131
  Not a defect, and recorded so nobody "fixes" it: `Prospective.observer` reads
128
132
  `store.observer` and never re-derives the predicate (`docs/observer-mode.md` G7, and
129
133
  `recall/`'s INTERFACE-GAPS #4 says the same). If the predicate moves to