counterparts 0.3.13 → 0.3.14

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 (84) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/package.json +1 -1
  3. package/src/adapters/claude-code/bin/hook.mjs +4 -2
  4. package/src/adapters/claude-code/bin/hook.ts +11 -4
  5. package/src/adapters/claude-code/bin/nightly.ts +5 -1
  6. package/src/adapters/claude-code/bin/runner.ts +11 -3
  7. package/src/adapters/claude-code/doctor.ts +69 -5
  8. package/src/adapters/claude-code/embed-client.ts +3 -0
  9. package/src/adapters/cli/bin/counterparts.mjs +4 -2
  10. package/src/adapters/cli/bin/counterparts.ts +11 -3
  11. package/src/adapters/cli/commands.ts +65 -23
  12. package/src/adapters/cli/index.ts +1 -0
  13. package/src/adapters/cli/install.ts +22 -9
  14. package/src/adapters/cli/settle.ts +39 -2
  15. package/src/adapters/cli/wire.ts +4 -0
  16. package/src/adapters/config.ts +29 -1
  17. package/src/adapters/dashboard/NOTES.md +33 -0
  18. package/src/adapters/dashboard/bin/dashboard.mjs +4 -2
  19. package/src/adapters/dashboard/bin/dashboard.ts +11 -3
  20. package/src/adapters/dashboard/index.ts +14 -0
  21. package/src/adapters/dashboard/source.ts +0 -8
  22. package/src/adapters/dashboard/web/fired.ts +8 -0
  23. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -1
  24. package/src/adapters/dashboard/web/pages/health/sections/cycle.js +7 -10
  25. package/src/adapters/dashboard/web/pages/memories/memories.css +3 -0
  26. package/src/adapters/dashboard/web/pages/memories/row.js +5 -2
  27. package/src/adapters/dashboard/web/pages/memories/sections/hold.js +2 -1
  28. package/src/adapters/dashboard/web/pages/memories/sections/search.js +19 -3
  29. package/src/adapters/dashboard/web/server.ts +16 -4
  30. package/src/adapters/dashboard/web/shared/dates.js +6 -16
  31. package/src/adapters/dashboard/web/shared/memory-modal.js +21 -8
  32. package/src/adapters/dashboard/web/views/health.ts +11 -0
  33. package/src/adapters/dashboard/web/views/mechanism-panel.ts +8 -5
  34. package/src/adapters/dashboard/web/views/memories.ts +26 -7
  35. package/src/adapters/dashboard/web/views/memory-words.ts +16 -0
  36. package/src/adapters/dashboard/web/views/memory.ts +51 -2
  37. package/src/adapters/dashboard/web/views/mind.ts +31 -6
  38. package/src/adapters/empty-bunfig.toml +5 -0
  39. package/src/adapters/fired.ts +6 -2
  40. package/src/adapters/host-wiring.ts +4 -3
  41. package/src/adapters/log/index.ts +2 -2
  42. package/src/adapters/mcp/CONTRACT.md +16 -2
  43. package/src/adapters/mcp/INTERFACE-GAPS.md +15 -1
  44. package/src/adapters/mcp/NOTES.md +243 -0
  45. package/src/adapters/mcp/bin/serve.mjs +4 -2
  46. package/src/adapters/mcp/bin/serve.ts +11 -4
  47. package/src/adapters/mcp/facts.ts +72 -4
  48. package/src/adapters/mcp/meaning.ts +218 -15
  49. package/src/adapters/mcp/server.ts +1 -1
  50. package/src/adapters/mcp/tools.ts +81 -57
  51. package/src/adapters/plugin-run.sh +405 -33
  52. package/src/adapters/plugin.ts +14 -2
  53. package/src/adapters/runtime.ts +192 -17
  54. package/src/adapters/sessions.ts +2 -2
  55. package/src/core/associate/NOTES.md +10 -0
  56. package/src/core/bridge.ts +1 -1
  57. package/src/core/briefing.ts +20 -3
  58. package/src/core/contradictions.ts +56 -20
  59. package/src/core/counterpart.ts +39 -17
  60. package/src/core/dream/CONTRACT.md +4 -12
  61. package/src/core/dream/INTERFACE-GAPS.md +3 -2
  62. package/src/core/dream/NOTES.md +10 -0
  63. package/src/core/dream/index.ts +10 -52
  64. package/src/core/embed/static.ts +5 -1
  65. package/src/core/encode/INTERFACE-GAPS.md +2 -1
  66. package/src/core/encode/NOTES.md +12 -0
  67. package/src/core/encode/chunk.ts +6 -30
  68. package/src/core/encode/index.ts +0 -1
  69. package/src/core/encode/types.ts +1 -13
  70. package/src/core/handoff/last-here.ts +18 -2
  71. package/src/core/physics/CONTRACT.md +6 -0
  72. package/src/core/physics/NOTES.md +33 -2
  73. package/src/core/physics/index.ts +22 -7
  74. package/src/core/prospective/CONTRACT.md +3 -1
  75. package/src/core/prospective/NOTES.md +15 -0
  76. package/src/core/recall/time-ask.ts +154 -19
  77. package/src/core/self/CONTRACT.md +23 -3
  78. package/src/core/self/NOTES.md +64 -0
  79. package/src/core/self/behind.ts +6 -3
  80. package/src/core/self/briefing.ts +272 -11
  81. package/src/core/self/index.ts +50 -4
  82. package/src/core/sleep/NOTES.md +32 -0
  83. package/src/core/store/NOTES.md +16 -0
  84. package/src/core/time.ts +15 -0
@@ -11,13 +11,14 @@
11
11
  * What it reads (a working default, held lightly; the revisit may widen it):
12
12
  *
13
13
  * - **days**: "today", "yesterday", "this morning", a clock time
14
- * (`recency-ask.ts`'s reading, reused), "N days ago", "a few days ago",
14
+ * (`recency-ask.ts`'s reading, reused), "N days ago" (and "3-4 days ago",
15
+ * "3 or 4 days ago": both ends; review of #345), "a few days ago",
15
16
  * "the other day", "past N days", "recently", "last Saturday" (and "this
16
17
  * past Saturday": the most recent Saturday BEFORE today, so asked on a
17
18
  * Saturday it is a week ago; 2026-10-09). "This Saturday" and "on
18
19
  * Saturday" are not read: either can be the coming one;
19
- * - **weeks**: "last week" (Monday to Sunday), "this week", "N weeks ago",
20
- * "the past week";
20
+ * - **weeks**: "last week" (Monday to Sunday), "this week", "N weeks ago"
21
+ * (and "2-3 weeks ago": both weeks), "the past week";
21
22
  * - **months**: "last month", "this month", "in September", "early / mid /
22
23
  * late October", "the end of August";
23
24
  * - **dates**: `2026-09-21`, `2026-09`, `09-21`, `9/21` (month first),
@@ -30,7 +31,14 @@
30
31
  * that names a thing on it ("before the 7/22 flight", "after July 22's
31
32
  * standup") keeps its own day under "before" and "after" (review of #338).
32
33
  * An open end is `OPEN_START` / `OPEN_END`, and a bounded window never
33
- * stretches;
34
+ * stretches. A month and day with no year under "since" or "after" that
35
+ * has not come yet this year is last year's ("since 10/25" asked on
36
+ * 10-03); under "before", "until" or "by" one whose month has not begun
37
+ * is this year's when that is nearer than last year's ("by 12/20" asked
38
+ * on 10-09; "until Dec 30" asked on Jan 3 is still last year's). An amount is not a date: "7-8 hours", "3/4 cup", "$5-10", and a
39
+ * fraction after a word of quantity ("cut it by 1/2"; "finish by 1/2" is
40
+ * still January 2) (2026-10-09); a leading zero ("09-28 minutes") keeps
41
+ * it a date (review of #345);
34
42
  * - **anchors**: an event ("around the cut-over", "during the release") or
35
43
  * the last session ("where did we leave off", "last session"). This file
36
44
  * only names them; the caller resolves them against the store, because a
@@ -44,7 +52,7 @@
44
52
  * Deliberate only, and facts only. NO MODEL CALL: fixed lists and the store's
45
53
  * clock. Pure: `now` and `zone` come in.
46
54
  */
47
- import { addDays, daysBetween, localDate, parseCalendarDate } from "../time.js";
55
+ import { addDays, daysBetween, isDay, localDate, parseCalendarDate } from "../time.js";
48
56
  import { readRecencyAsk } from "./recency-ask.js";
49
57
 
50
58
  /** Days a fuzzy window (a week, a month, part of a month) widens on each side. */
@@ -109,11 +117,60 @@ const WEEKDAY_NAMES = ["sunday", "monday", "tuesday", "wednesday", "thursday", "
109
117
  const BOUND_ALT = "prior to|up until|up to|before|after|since|until|till|by";
110
118
  type Bound = "before" | "after" | "since" | "through";
111
119
 
120
+ /**
121
+ * A `7-8` or a `1/2` with one of these right after it is an amount, not a
122
+ * date: "7-8 hours", "3-4pm", "5-10%", "3/4 cup", "1/2 of the budget" (review
123
+ * of #338, 2026-10-09). Units and a few counting nouns; a decimal tail
124
+ * ("7-8.5 hours") is allowed in front of it.
125
+ */
126
+ const QUANTITY_AFTER = new RegExp(
127
+ "^(?:\\.\\d+)?\\s*(?:%|(?:" +
128
+ [
129
+ "seconds?", "secs?", "minutes?", "mins?", "hours?", "hrs?", "hr", "days?", "nights?", "weeks?", "wks?",
130
+ "months?", "mos", "years?", "yrs?", "decades?",
131
+ "a\\.?m\\.?", "p\\.?m\\.?", "o['’]clock",
132
+ "percent", "pct", "times", "x", "reps", "sets", "laps", "pages?", "words", "steps",
133
+ "people", "persons?", "kids", "items", "points?", "pts",
134
+ "km", "kms", "kilomet(?:er|re)s?", "miles?", "mi", "met(?:er|re)s?", "ft", "feet", "foot", "inch(?:es)?",
135
+ "cm", "mm", "yards?", "yds?", "kg", "kgs", "kilos?", "grams?", "lbs?", "pounds?", "oz", "ounces?",
136
+ "cups?", "tbsp", "tsp", "teaspoons?", "tablespoons?", "lit(?:er|re)s?", "ml", "gallons?", "gal", "pints?",
137
+ "quarts?", "servings?", "slices?", "pieces?", "dollars?", "bucks", "cents?", "euros?", "k",
138
+ "mph", "kph", "bpm", "rpm", "mg", "of",
139
+ ].join("|") +
140
+ ")(?![a-z]))",
141
+ "i",
142
+ );
143
+
144
+ /**
145
+ * A word of quantity a few words before "by" or "to": what follows it is a
146
+ * fraction ("cut it by 1/2", "reduced the dose to 1/3"), where "finish by
147
+ * 1/2" is January 2 (review of #338, 2026-10-09).
148
+ */
149
+ const FRACTION_BEFORE = new RegExp(
150
+ "\\b(?:" +
151
+ [
152
+ "cut", "cuts", "cutting", "halve[sd]?", "halving", "reduc(?:e|es|ed|ing)", "increas(?:e|es|ed|ing)",
153
+ "decreas(?:e|es|ed|ing)", "divid(?:e|es|ed|ing)", "multipl(?:y|ies|ied|ying)", "grow", "grows", "grew",
154
+ "grown", "growing", "shr(?:ink|inks|ank|unk|inking)", "rais(?:e|es|ed|ing)", "lower(?:s|ed|ing)?",
155
+ "trim(?:s|med|ming)?", "slash(?:es|ed|ing)?", "boost(?:s|ed|ing)?", "scal(?:e|es|ed|ing)",
156
+ "drop(?:s|ped|ping)?", "fall", "falls", "fell", "fallen", "falling", "rise", "rises", "rose", "risen", "rising",
157
+ ].join("|") +
158
+ ")\\b(?:\\s+[a-z'’]+){0,3}\\s+(?:by|to)\\s*$",
159
+ "i",
160
+ );
161
+
112
162
  const NUMBER_WORDS: Readonly<Record<string, number>> = {
113
163
  a: 1, an: 1, one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10,
114
164
  eleven: 11, twelve: 12, couple: 2, "a couple": 2, "a couple of": 2, few: 3, "a few": 3,
115
165
  };
116
166
  const NUMBER_ALT = "\\d{1,3}|a couple of|a couple|a few|couple|few|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|an|a";
167
+ /**
168
+ * The near end of a range in front of a count: the "2-" of "2-3 weeks ago",
169
+ * the "3 or " of "3 or 4 days ago". The amount rule passes "2-3" over, so
170
+ * without it the count alone was read ("3 weeks ago", hiding the week two
171
+ * back; review of #345).
172
+ */
173
+ const RANGE_FROM = "(?:(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven)\\s*(?:-|–|/|\\sor\\s|\\sto\\s)\\s*)?";
117
174
 
118
175
  /** Words that end an event phrase: what follows is the question, not the event. */
119
176
  const PHRASE_STOP = new Set([
@@ -216,10 +273,41 @@ function boundOf(text: string, found: string): { bound: Bound; word: string; phr
216
273
  * A date read off the question — its first and last day, and its stretch
217
274
  * standing alone — asked as a whole or bounded by the word in front of it.
218
275
  * `cue` is how the header names it, when that is not the text as found.
276
+ * `yearless`: a month and day written without a year, whose year `yearFor`
277
+ * picked by the month alone.
219
278
  */
220
- function dated(text: string, found: string, first: string, last: string, stretch: number, today: string, cue = found): TimeAsk {
279
+ function dated(
280
+ text: string,
281
+ found: string,
282
+ firstDay: string,
283
+ lastDay: string,
284
+ stretch: number,
285
+ today: string,
286
+ opts: { cue?: string; yearless?: boolean } = {},
287
+ ): TimeAsk {
288
+ const cue = opts.cue ?? found;
221
289
  const b = boundOf(text, found);
222
- if (b === null) return ask(cue, { from: first, to: last }, stretch, without(text, found));
290
+ if (b === null) return ask(cue, { from: firstDay, to: lastDay }, stretch, without(text, found));
291
+ // "Since 10/25" asked on 10-03 is last year's 10/25: this year's has not
292
+ // come, so "since" would be empty and "after" only the future. "Before",
293
+ // "until" and "by" keep this year's, which hides nothing that has happened
294
+ // (review of #338, 2026-10-09).
295
+ const roll = opts.yearless === true && (b.bound === "since" || b.bound === "after") && firstDay > today;
296
+ // And the other way (review of #345): "by 12/20" asked on 10-09 is THIS
297
+ // year's 12/20, though its month has not begun. `yearFor` put it last year,
298
+ // which cut the window at 2025-12-20 and hid the ten months since; a cutoff
299
+ // still ahead hides nothing. Only when this year's is the nearer of the two,
300
+ // so "until Dec 30" asked on Jan 3 is still the one four days back. A Feb 29
301
+ // this year lacks stays where it was.
302
+ const thisYears = `${today.slice(0, 4)}${firstDay.slice(4)}`;
303
+ const ahead =
304
+ opts.yearless === true &&
305
+ (b.bound === "before" || b.bound === "through") &&
306
+ firstDay.slice(0, 4) < today.slice(0, 4) &&
307
+ isDay(thisYears) &&
308
+ daysBetween(today, thisYears) <= daysBetween(firstDay, today);
309
+ const first = roll ? lastCome(firstDay, today) : ahead ? thisYears : firstDay;
310
+ const last = roll || ahead ? first : lastDay;
223
311
  if (b.event !== null) {
224
312
  // The date names a thing on that day ("before the 7/22 flight"): the bound
225
313
  // keeps that day, where the thing happened, and only the date leaves the
@@ -246,6 +334,47 @@ function yearFor(month: number, today: string): number {
246
334
  return month <= m ? y : y - 1;
247
335
  }
248
336
 
337
+ /**
338
+ * The most recent time the month and day of `day` came round, on or before
339
+ * `today`: a year back, or further for a Feb 29 (a year with none is skipped).
340
+ */
341
+ function lastCome(day: string, today: string): string {
342
+ const monthDay = day.slice(4);
343
+ for (let y = Number(day.slice(0, 4)) - 1; y >= 1; y--) {
344
+ const back = `${String(y).padStart(4, "0")}${monthDay}`;
345
+ if (back <= today && isDay(back)) return back;
346
+ }
347
+ return day;
348
+ }
349
+
350
+ /**
351
+ * Is this `M-D` or `M/D` an amount rather than a date? A price ("$5-10"), a
352
+ * number with a unit after it ("7-8 hours", "3/4 cup", "1/2 of it"), or a
353
+ * common fraction after a word of quantity ("cut it by 1/2", "reduced to
354
+ * 1/3": a slash, no year, smaller over at most 10). Otherwise a date, so
355
+ * "finish by 1/2" is still January 2 (review of #338, 2026-10-09). A number
356
+ * written with a leading zero ("09-28 minutes", "7/08 people") is a date:
357
+ * no amount is written that way (review of #345).
358
+ */
359
+ function isQuantity(text: string, m: RegExpExecArray): boolean {
360
+ if (/^0\d$/.test(m[1] as string) || /^0\d$/.test(m[2] as string)) return false;
361
+ const before = text.slice(0, m.index);
362
+ if (/[$£€]$/.test(before)) return true;
363
+ if (QUANTITY_AFTER.test(text.slice(m.index + m[0].length))) return true;
364
+ const over = Number(m[1]);
365
+ const under = Number(m[2]);
366
+ return m[3] === undefined && m[0].includes("/") && over < under && under <= 10 && FRACTION_BEFORE.test(before);
367
+ }
368
+
369
+ /** The first `M-D` / `M/D` (a `/YYYY` after it allowed) in `text` that is not an amount. */
370
+ function firstShortDate(text: string): RegExpExecArray | null {
371
+ const re = /\b(\d{1,2})[-/](\d{1,2})(?:[-/](\d{4}))?\b/g;
372
+ for (let m = re.exec(text); m !== null; m = re.exec(text)) {
373
+ if (!isQuantity(text, m)) return m;
374
+ }
375
+ return null;
376
+ }
377
+
249
378
  /** Remove `found` (and a preposition just before it) from `text`, once. */
250
379
  function without(text: string, found: string): string {
251
380
  const at = text.toLowerCase().indexOf(found.toLowerCase());
@@ -320,14 +449,15 @@ export function readTimeAsk(text: string, clock: { now: number; zone: string }):
320
449
  }
321
450
  }
322
451
  // Month first, as a US writer puts it; a year after it is the year meant.
323
- const short = /\b(\d{1,2})[-/](\d{1,2})(?:[-/](\d{4}))?\b/.exec(text);
452
+ // An amount is passed over ("7-8 hours", "cut it by 1/2").
453
+ const short = firstShortDate(text);
324
454
  if (short !== null) {
325
455
  const m = Number(short[1]);
326
456
  const d = Number(short[2]);
327
457
  const y = short[3] !== undefined ? Number(short[3]) : m >= 1 && m <= 12 ? yearFor(m, today) : 0;
328
458
  const day = m >= 1 && m <= 12 ? `${String(y).padStart(4, "0")}-${pad(m)}-${pad(d)}` : null;
329
459
  if (day !== null && parseCalendarDate(day)?.precision === "day") {
330
- return dated(text, short[0], day, day, 0, today);
460
+ return dated(text, short[0], day, day, 0, today, { yearless: short[3] === undefined });
331
461
  }
332
462
  }
333
463
  const named = new RegExp(
@@ -341,7 +471,7 @@ export function readTimeAsk(text: string, clock: { now: number; zone: string }):
341
471
  if (month !== null) {
342
472
  const day = `${String(year !== undefined ? Number(year) : yearFor(month, today)).padStart(4, "0")}-${pad(month)}-${pad(d)}`;
343
473
  if (parseCalendarDate(day)?.precision === "day") {
344
- return dated(text, named[0], day, day, 0, today);
474
+ return dated(text, named[0], day, day, 0, today, { yearless: year === undefined });
345
475
  }
346
476
  }
347
477
  }
@@ -406,11 +536,14 @@ export function readTimeAsk(text: string, clock: { now: number; zone: string }):
406
536
  if (pastWeek !== null) {
407
537
  return ask(pastWeek[0], { from: addDays(today, -6), to: today }, 0, without(text, pastWeek[0]));
408
538
  }
409
- const weeksAgo = new RegExp(`\\b(${NUMBER_ALT})\\s+weeks?\\s+ago\\b`, "i").exec(text);
539
+ const weeksAgo = new RegExp(`\\b${RANGE_FROM}(${NUMBER_ALT})\\s+weeks?\\s+ago\\b`, "i").exec(text);
410
540
  if (weeksAgo !== null) {
411
- const n = numberOf(weeksAgo[1] as string) ?? 1;
412
- const monday = addDays(mondayOf(today), -7 * n);
413
- return ask(weeksAgo[0], { from: monday, to: addDays(monday, 6) }, FUZZY_STRETCH_DAYS, without(text, weeksAgo[0]));
541
+ const n = numberOf(weeksAgo[2] as string) ?? 1;
542
+ // "2-3 weeks ago": from the Monday of the further week to the Sunday of the nearer.
543
+ const near = weeksAgo[1] === undefined ? n : Math.min(n, numberOf(weeksAgo[1]) ?? n);
544
+ const far = weeksAgo[1] === undefined ? n : Math.max(n, numberOf(weeksAgo[1]) ?? n);
545
+ const monday = addDays(mondayOf(today), -7 * far);
546
+ return ask(weeksAgo[0], { from: monday, to: addDays(mondayOf(today), -7 * near + 6) }, FUZZY_STRETCH_DAYS, without(text, weeksAgo[0]));
414
547
  }
415
548
  const fewWeeks = /\b(the\s+)?(past|last)\s+(few|couple of|two|three)\s+weeks\b/i.exec(text);
416
549
  if (fewWeeks !== null) {
@@ -426,7 +559,7 @@ export function readTimeAsk(text: string, clock: { now: number; zone: string }):
426
559
  const weekday = new RegExp(`(?<!\\bthe\\s)\\b(?:last|this past)\\s+(${WEEKDAY_NAMES.join("|")})\\b(?:['’]s\\b)?`, "i").exec(text);
427
560
  if (weekday !== null) {
428
561
  const day = lastWeekday(today, WEEKDAY_NAMES.indexOf((weekday[1] as string).toLowerCase() as (typeof WEEKDAY_NAMES)[number]));
429
- return dated(text, weekday[0], day, day, 0, today, weekday[0].replace(/['’]s$/i, ""));
562
+ return dated(text, weekday[0], day, day, 0, today, { cue: weekday[0].replace(/['’]s$/i, "") });
430
563
  }
431
564
  // Before "yesterday" is read on its own (review of #323).
432
565
  const dayBefore = /\bthe day before yesterday\b/i.exec(text);
@@ -434,15 +567,17 @@ export function readTimeAsk(text: string, clock: { now: number; zone: string }):
434
567
  const day = addDays(today, -2);
435
568
  return ask(dayBefore[0], { from: day, to: day }, 0, without(text, dayBefore[0]));
436
569
  }
437
- const daysAgo = new RegExp(`\\b(${NUMBER_ALT})\\s+days?\\s+ago\\b`, "i").exec(text);
570
+ const daysAgo = new RegExp(`\\b${RANGE_FROM}(${NUMBER_ALT})\\s+days?\\s+ago\\b`, "i").exec(text);
438
571
  if (daysAgo !== null) {
439
- const word = (daysAgo[1] as string).toLowerCase();
572
+ const word = (daysAgo[2] as string).toLowerCase();
440
573
  if (word === "few" || word === "a few" || word === "couple" || word === "a couple" || word === "a couple of") {
441
574
  return ask(daysAgo[0], { from: addDays(today, -5), to: addDays(today, -2) }, NEAR_STRETCH_DAYS, without(text, daysAgo[0]));
442
575
  }
443
576
  const n = numberOf(word) ?? 1;
444
- const day = addDays(today, -n);
445
- return ask(daysAgo[0], { from: day, to: day }, NEAR_STRETCH_DAYS, without(text, daysAgo[0]));
577
+ // "3-4 days ago": every day from the further to the nearer.
578
+ const near = daysAgo[1] === undefined ? n : Math.min(n, numberOf(daysAgo[1]) ?? n);
579
+ const far = daysAgo[1] === undefined ? n : Math.max(n, numberOf(daysAgo[1]) ?? n);
580
+ return ask(daysAgo[0], { from: addDays(today, -far), to: addDays(today, -near) }, NEAR_STRETCH_DAYS, without(text, daysAgo[0]));
446
581
  }
447
582
  if (/\bthe other day\b/i.test(text)) {
448
583
  return ask("the other day", { from: addDays(today, -5), to: addDays(today, -2) }, NEAR_STRETCH_DAYS, without(text, "the other day"));
@@ -183,7 +183,21 @@ proposals and their archive; render and delivery telemetry.
183
183
  only while the whole still fits the budget, lanes that trim last first; one that does
184
184
  not fit is left out and the trim's count stays in telemetry. Identity says nothing
185
185
  while the page replaces the list, and Nearby says nothing at all since 2026-10-01: what
186
- it leaves out is the rest of the warm store, which recall finds by asking.
186
+ it leaves out is the rest of the warm store, which recall finds by asking. **A lane that
187
+ kept no element is one line, its heading inside it** (2026-10-09,
188
+ `briefing.ts#collapsedLine`): `Still open: 20 — no room to list them in this wake;
189
+ recall ids …`, never a heading over a count. **The page is never cut for the lanes
190
+ beside it** (review of #350): it prints whole under its cap, `min(PAGE_WAKE_BYTES,
191
+ budget − PAGE_FLOOR_RESERVE_BYTES)`. **"Still open" keeps its first item and its count
192
+ before Arriving keeps its second line** (2026-10-09, a working default; the one
193
+ exception to the trim order above, `briefing.ts#keepFirstOpen`): when the trim loop fits
194
+ with "Still open" empty, the room for its first item and its "N more" line comes, in
195
+ order, out of the room the delivery holds for "Work here" (`lendBytes`, the caller's
196
+ work reserve — the delivery then shows fewer work lines, and the render's `budgetBytes`
197
+ states what it borrowed), Arriving beyond its first line, and the Yesterday line's
198
+ titles (`yesterdayShorter`, fewer titles and the rest by count). All or nothing: when
199
+ even that leaves no room, or the trim already took Arriving's first line, the render is
200
+ the trim loop's, and the lane collapses to its one line.
187
201
  **What Nearby and the horizon leave out** (2026-10-01, working defaults): a memory a
188
202
  later one settled over (`changed` or `corrected`) is in no lane but identity; a memory
189
203
  arriving is under Arriving only; and a hint the self page already covers — cited by the
@@ -233,8 +247,14 @@ proposals and their archive; render and delivery telemetry.
233
247
  `- YYYY-MM-DD (of YYYY-MM-DD) · statement` when the content date differs (neutral,
234
248
  because the horizon lane's dates are in the future), `- YYYY-MM-DD (due YYYY-MM-DD) ·
235
249
  statement` for an arriving occasion (2026-10-01) — `(due YYYY-MM-DD, every May 14)`
236
- when its date repeats (2026-10-09) — and no prefix when the statement
237
- already opens with that same date. Leading, not trailing: the age is
250
+ when its date repeats (2026-10-09), `- due YYYY-MM-DD · statement` when it is due on
251
+ the day it was learned (a migrated row's `by` bound is not printed there: the due date
252
+ is the line's claim), and `was due` for a date already behind the day the wake was
253
+ composed for (2026-10-09) — and no prefix when the statement
254
+ already opens with that same date. **The delivery puts an Arriving date in the past
255
+ tense** (2026-10-09, `briefing.ts#arrivingTense`): it alone knows the reading day, so a
256
+ line due before it reads `(was due YYYY-MM-DD)`, `(was due yesterday, YYYY-MM-DD)` the
257
+ day after — inside the preface's reserve, and only the date prefix of an Arriving line. Leading, not trailing: the age is
238
258
  read before the claim, the element's own text still ends the line, and it costs 14 bytes
239
259
  at day precision against 21 for a trailing form — counted in the composed budget and in
240
260
  the identity share, on the same line the sentinel counts. The element text itself is
@@ -1598,3 +1598,67 @@ a one-off date, the parenthesis stays when the occurrence falls on the learned d
1598
1598
  "every May 14" is news even then. One change to what the lane selects (review of #339): a
1599
1599
  DAILY repeat takes no line (`prospective/` NOTES §15) — rendered the evening before, it
1600
1600
  would read as due yesterday.
1601
+
1602
+ ## 2026-10-09 — "Still open" over nothing, and an Arriving line a day late
1603
+
1604
+ The owner's wake that morning read `Still open:` and, under it, only `(20 more still open;
1605
+ recall ids (the first 5): …)`; and an Arriving reminder due 10-08 read `(due 2026-10-08)`.
1606
+
1607
+ - **Why no item fit.** Not the lane's items alone and not a lane share — the lane had no
1608
+ share at all. The page is furniture the trim cannot pop, so `Self#pageBlock` cuts it
1609
+ before the lanes compose, to `min(PAGE_WAKE_BYTES, budget − PAGE_FLOOR_RESERVE_BYTES)`:
1610
+ room for the wake's own furniture and nothing else. The delivery reserves (preface,
1611
+ handoff, work lines) bring a 9,000-byte host to a compose budget near 7 KB, the page
1612
+ takes ~6 KB of it, the Yesterday line (furniture) rides whole, and Arriving trims AFTER
1613
+ "Still open". Reproduced with 25 open items (~276-byte lines), a 7 KB page, a 300-byte
1614
+ Yesterday line and two Arriving lines: at compose budgets 7,100–7,250 the page showed
1615
+ 5,961 bytes and "Still open:" printed over `(25 more still open; …)` — the room left
1616
+ (~150–290 bytes) held the 150-byte "more" line but not one item and its heading.
1617
+ - **The floor — first drafted out of the page, and moved off it in review (#350).** The
1618
+ first draft cut the page to leave the Yesterday line, Arriving and 768 bytes of "Still
1619
+ open" their room (never below half the budget). Measured at the 9,000 default with a
1620
+ 349-byte Yesterday line and two Arriving lines (compose budget 7,205): the page's cap
1621
+ fell from 6,144 to 5,361, and the owner's 5,845-byte page (version 16) printed 5,098 —
1622
+ the self the wake exists for, cut to make room for a list. So the page keeps its old
1623
+ cap, `min(PAGE_WAKE_BYTES, budget − PAGE_FLOOR_RESERVE_BYTES)`, and the room comes out
1624
+ of the lanes instead (`keepFirstOpen`): only when the trim loop fits with "Still open"
1625
+ empty, the lane's first item AND its "N more" line (one item with no count reads as the
1626
+ only thing open) are put back, and what gives way is, in order, the room the delivery
1627
+ holds for "Work here" (lent: the composition may run past its budget by up to the work
1628
+ reserve, the delivery then shows fewer work lines, and the render's `budgetBytes`
1629
+ states what it borrowed so Health's "runs over its ceiling" stays true), Arriving
1630
+ beyond its first line, and the Yesterday line's titles (shorter forms the root
1631
+ composes, fewer titles and the rest by count). All or nothing, and never past
1632
+ Arriving's first line, which the trim order still ranks above the first open item.
1633
+ Same scenario after: 5,845 → whole, one item and `(24 more …)` inside the budget, nothing
1634
+ lent; 6,100 and 6,144 → whole, one item and its count on 213 and 257 lent bytes, both
1635
+ Arriving lines and all four Yesterday titles kept, and "Work here" at four lines (the
1636
+ reserves' margins covered it) and three. The delivered wake then sits near the
1637
+ ceiling, so the clock line above it goes over by a few bytes — counted by doctor,
1638
+ never amber, as for any full wake (review of #318). Without the lend
1639
+ the same two drop Arriving's second line and two or three Yesterday titles. One item,
1640
+ not two: every byte past the first is taken from a reminder or from yesterday.
1641
+ Without a page the identity share already leaves the lane its room (5 of 25 listed).
1642
+ - **The backstop.** A lane (not identity) that keeps no element and has something to say
1643
+ about what it left out is ONE line with its heading in it (`collapsedLine`): `Still
1644
+ open: 25 — no room to list them in this wake; recall ids (the first 5): …`. No "more":
1645
+ more than none is not a count. The dashboard's splitters read the lane off the line
1646
+ (`collapsedLane`). Seen in the same scenario at a 2,000-byte compose budget.
1647
+ - **The Arriving line, by design and now said truly.** A quiet one-off stays in the
1648
+ horizon lane through its grace days (`prospective/` GRACE_DAYS, 7), and the wake is
1649
+ composed at a boundary and read later — the 10-08 evening's render read on the 9th.
1650
+ `(due 2026-10-08)` was a true date under a heading that reads as "still to come". The
1651
+ render now says `(was due …)` for a date already behind the day it was composed for
1652
+ (`HorizonItem.past`, set by `core/briefing.ts#selfRenderer` from its `at`), and the
1653
+ delivery — which alone knows the morning — says `(was due yesterday, 2026-10-08)` the
1654
+ day after and `(was due 2026-10-05)` later (`arrivingTense`, beside the preface, with
1655
+ the same date). It touches only the date prefix of an Arriving `- ` line, in what the
1656
+ preface's reserve leaves: "was " on every such line fits even beside the widest preface
1657
+ at `HORIZON_MAX` lines (tested); "yesterday, " is added while room is left. A due date
1658
+ equal to the learned date is now printed as `due YYYY-MM-DD ·` rather than the learned
1659
+ date alone, so the line says when and the delivery has a date to turn.
1660
+ - **A plain reminder told on its day was still there the next morning** — reproduced:
1661
+ when the day's first render runs before the telling (a late session's turn ending after
1662
+ midnight), nothing re-rendered after it, so the told reminder stayed under "Arriving:"
1663
+ through the day and into the next morning. The claim now marks the wake behind
1664
+ (`told`, `behind.ts`), and the next turn-end worker re-renders it.
@@ -35,10 +35,13 @@ export const WAKE_CAUGHT_KEY = "self.wake.caught";
35
35
  export const WAKE_BUILD_KEY = "self.wake.build";
36
36
 
37
37
  /** What made the wake behind: the self page written, a write-up landed, the
38
- * nightly run ended, or the bundle was published by another build. */
39
- export type WakeTrigger = "page" | "write-up" | "run-end" | "version";
38
+ * nightly run ended, the bundle was published by another build, or a plain
39
+ * reminder was told on its day (`told`, 2026-10-09) — told, it leaves
40
+ * "Arriving:", and a wake composed before the telling would still list it
41
+ * the next morning. */
42
+ export type WakeTrigger = "page" | "write-up" | "run-end" | "version" | "told";
40
43
 
41
- export const WAKE_TRIGGERS: readonly WakeTrigger[] = ["page", "write-up", "run-end", "version"];
44
+ export const WAKE_TRIGGERS: readonly WakeTrigger[] = ["page", "write-up", "run-end", "version", "told"];
42
45
 
43
46
  /** The mark as it stands, with its raw value — the thing a render records as caught. */
44
47
  export interface WakeBehind {