counterparts 0.3.11 → 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.
- package/CHANGELOG.md +326 -0
- package/docs/QUICKSTART.md +5 -0
- package/docs/README.md +2 -2
- package/docs/module-map.md +3 -3
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +36 -10
- package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
- package/src/adapters/claude-code/NOTES.md +182 -0
- package/src/adapters/claude-code/bin/hook.ts +46 -12
- package/src/adapters/claude-code/bin/runner.ts +7 -1
- package/src/adapters/claude-code/doctor.ts +632 -18
- package/src/adapters/claude-code/hooks.ts +61 -16
- package/src/adapters/claude-code/index.ts +11 -0
- package/src/adapters/claude-code/night-run.ts +150 -14
- package/src/adapters/claude-code/transcript.ts +268 -1
- package/src/adapters/cli/CONTRACT.md +5 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
- package/src/adapters/cli/NOTES.md +111 -0
- package/src/adapters/cli/commands.ts +134 -92
- package/src/adapters/cli/dream-core.ts +57 -42
- package/src/adapters/cli/export.ts +320 -21
- package/src/adapters/cli/help.ts +2 -1
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +39 -7
- package/src/adapters/cli/mechanisms.ts +7 -1
- package/src/adapters/cli/uninstall.ts +13 -5
- package/src/adapters/cli/wire.ts +189 -63
- package/src/adapters/config.ts +2 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
- package/src/adapters/dashboard/NOTES.md +79 -0
- package/src/adapters/dashboard/registries.ts +34 -2
- package/src/adapters/dashboard/web/README.md +19 -14
- package/src/adapters/dashboard/web/actions.ts +23 -1
- package/src/adapters/dashboard/web/flow.ts +14 -0
- package/src/adapters/dashboard/web/lanes.ts +10 -0
- package/src/adapters/dashboard/web/narrate.ts +88 -2
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
- package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
- package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
- package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
- package/src/adapters/dashboard/web/server.ts +0 -5
- package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
- package/src/adapters/dashboard/web/views/health.ts +21 -3
- package/src/adapters/dashboard/web/views/search.ts +4 -45
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +430 -28
- package/src/adapters/host-wiring.ts +300 -0
- package/src/adapters/hosts.ts +11 -0
- package/src/adapters/lifecycle.ts +42 -2
- package/src/adapters/log/index.ts +9 -0
- package/src/adapters/mcp/CONTRACT.md +151 -11
- package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
- package/src/adapters/mcp/NOTES.md +313 -1
- package/src/adapters/mcp/bin/serve.ts +74 -1
- package/src/adapters/mcp/deliberate.ts +169 -651
- package/src/adapters/mcp/facts.ts +1094 -0
- package/src/adapters/mcp/index.ts +25 -7
- package/src/adapters/mcp/meaning.ts +1610 -0
- package/src/adapters/mcp/server.ts +835 -150
- package/src/adapters/mcp/stdio.ts +3 -1
- package/src/adapters/mcp/stood-down.ts +51 -0
- package/src/adapters/mcp/tools.ts +167 -41
- package/src/adapters/plugin-run.sh +133 -0
- package/src/adapters/plugin.ts +329 -0
- package/src/adapters/sessions.ts +18 -4
- package/src/core/associate/CONTRACT.md +2 -1
- package/src/core/associate/INTERFACE-GAPS.md +6 -1
- package/src/core/associate/NOTES.md +45 -0
- package/src/core/briefing.ts +12 -3
- package/src/core/contradictions.ts +184 -0
- package/src/core/counterpart.ts +797 -51
- package/src/core/dream/CONTRACT.md +36 -4
- package/src/core/dream/INTERFACE-GAPS.md +29 -6
- package/src/core/dream/NOTES.md +107 -0
- package/src/core/dream/feeling-weeks.ts +198 -0
- package/src/core/dream/index.ts +109 -18
- package/src/core/dream/reflect.ts +346 -87
- package/src/core/dream/tunables.ts +24 -4
- package/src/core/encode/INTERFACE-GAPS.md +3 -1
- package/src/core/encode/NOTES.md +7 -0
- package/src/core/encode/words.ts +45 -0
- package/src/core/fit/INTERFACE-GAPS.md +8 -2
- package/src/core/fit/NOTES.md +39 -1
- package/src/core/fit/index.ts +40 -0
- package/src/core/handoff/CONTRACT.md +37 -2
- package/src/core/handoff/INTERFACE-GAPS.md +10 -0
- package/src/core/handoff/NOTES.md +72 -0
- package/src/core/handoff/index.ts +214 -12
- package/src/core/handoff/last-here.ts +6 -4
- package/src/core/mint.ts +12 -2
- package/src/core/physics/CONTRACT.md +14 -2
- package/src/core/physics/NOTES.md +33 -1
- package/src/core/physics/index.ts +28 -5
- package/src/core/prospective/CONTRACT.md +45 -6
- package/src/core/prospective/INTERFACE-GAPS.md +4 -0
- package/src/core/prospective/NOTES.md +138 -0
- package/src/core/prospective/derive.ts +33 -5
- package/src/core/prospective/index.ts +90 -5
- package/src/core/prospective/windows.ts +72 -1
- package/src/core/recall/CONTRACT.md +31 -12
- package/src/core/recall/INTERFACE-GAPS.md +28 -4
- package/src/core/recall/NOTES.md +70 -1
- package/src/core/recall/feeling-ask.ts +10 -1
- package/src/core/recall/index.ts +3 -1
- package/src/core/recall/probe.ts +58 -0
- package/src/core/recall/session.ts +46 -2
- package/src/core/recall/time-ask.ts +487 -0
- package/src/core/remember/CONTRACT.md +4 -1
- package/src/core/remember/INTERFACE-GAPS.md +9 -1
- package/src/core/remember/NOTES.md +8 -0
- package/src/core/remember/proposals.ts +47 -5
- package/src/core/revision.ts +18 -1
- package/src/core/schemas/CONTRACT.md +21 -1
- package/src/core/schemas/INTERFACE-GAPS.md +20 -2
- package/src/core/schemas/NOTES.md +144 -0
- package/src/core/schemas/aliases.ts +55 -5
- package/src/core/schemas/index.ts +93 -1
- package/src/core/schemas/types.ts +2 -0
- package/src/core/self/CONTRACT.md +32 -5
- package/src/core/self/INTERFACE-GAPS.md +7 -2
- package/src/core/self/NOTES.md +102 -1
- package/src/core/self/behind.ts +43 -3
- package/src/core/self/briefing.ts +12 -2
- package/src/core/self/chapter-address.ts +254 -0
- package/src/core/self/episodes.ts +27 -0
- package/src/core/self/index.ts +83 -8
- package/src/core/self/page.ts +88 -0
- package/src/core/self/tunables.ts +5 -0
- package/src/core/self/work.ts +35 -2
- package/src/core/self/writer.ts +30 -0
- package/src/core/sleep/INTERFACE-GAPS.md +22 -3
- package/src/core/sleep/NOTES.md +20 -1
- package/src/core/sleep/consolidate.ts +59 -7
- package/src/core/sleep/index.ts +3 -0
- package/src/core/sleep/prune.ts +6 -2
- package/src/core/sleep/types.ts +7 -0
- package/src/core/store/CONTRACT.md +16 -0
- package/src/core/store/NOTES.md +66 -0
- package/src/core/store/feelings.ts +14 -1
- package/src/core/store/index.ts +483 -16
- package/src/core/store/operational.ts +95 -2
- package/src/core/store/owner-op-seam.ts +23 -0
- package/src/core/time.ts +152 -0
- package/tools/install-loop/run.sh +48 -12
- package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE TIME A FACTS QUESTION NAMES (2026-10-03, Release B of deliberate recall)
|
|
3
|
+
* — a sibling of `recency-ask.ts`, read by `mcp/facts.ts` only.
|
|
4
|
+
*
|
|
5
|
+
* Facts mode treats time in a question as a FILTER: only memories inside the
|
|
6
|
+
* window come back, with a count of the matches outside it. This file reads
|
|
7
|
+
* the window off the question, says how far it stretches, and hands back the
|
|
8
|
+
* question with the time words taken out — the rest is what the words and the
|
|
9
|
+
* meaning search, or "last week" would match every memory that says "week".
|
|
10
|
+
*
|
|
11
|
+
* What it reads (a working default, held lightly; the revisit may widen it):
|
|
12
|
+
*
|
|
13
|
+
* - **days**: "today", "yesterday", "this morning", a clock time
|
|
14
|
+
* (`recency-ask.ts`'s reading, reused), "N days ago", "a few days ago",
|
|
15
|
+
* "the other day", "past N days", "recently", "last Saturday" (and "this
|
|
16
|
+
* past Saturday": the most recent Saturday BEFORE today, so asked on a
|
|
17
|
+
* Saturday it is a week ago; 2026-10-09). "This Saturday" and "on
|
|
18
|
+
* 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";
|
|
21
|
+
* - **months**: "last month", "this month", "in September", "early / mid /
|
|
22
|
+
* late October", "the end of August";
|
|
23
|
+
* - **dates**: `2026-09-21`, `2026-09`, `09-21`, `9/21` (month first),
|
|
24
|
+
* `9/21/2026`, "Sep 21", "September 21st", "21 September", "September 21,
|
|
25
|
+
* 2026" — a year written with the date is the year meant; without one,
|
|
26
|
+
* `yearFor` picks it. A word in front of a date bounds it (2026-10-09):
|
|
27
|
+
* "since" runs from the date to today (a month too); "before" / "prior to"
|
|
28
|
+
* is every day before it, "after" every day after it, open-ended; "until",
|
|
29
|
+
* "till", "up to", "up until" and "by" every day through it — but a date
|
|
30
|
+
* that names a thing on it ("before the 7/22 flight", "after July 22's
|
|
31
|
+
* standup") keeps its own day under "before" and "after" (review of #338).
|
|
32
|
+
* An open end is `OPEN_START` / `OPEN_END`, and a bounded window never
|
|
33
|
+
* stretches;
|
|
34
|
+
* - **anchors**: an event ("around the cut-over", "during the release") or
|
|
35
|
+
* the last session ("where did we leave off", "last session"). This file
|
|
36
|
+
* only names them; the caller resolves them against the store, because a
|
|
37
|
+
* date for "the cut-over" is a search, and "the last session" is a fact
|
|
38
|
+
* about this directory's sessions.
|
|
39
|
+
*
|
|
40
|
+
* STRETCH. A fuzzy window (a week, a month, part of a month) widens two days
|
|
41
|
+
* each side, a near one ("3 days ago") one day; a named day or date stays
|
|
42
|
+
* exact. `said` is the window as asked, `window` the one that filters.
|
|
43
|
+
*
|
|
44
|
+
* Deliberate only, and facts only. NO MODEL CALL: fixed lists and the store's
|
|
45
|
+
* clock. Pure: `now` and `zone` come in.
|
|
46
|
+
*/
|
|
47
|
+
import { addDays, daysBetween, localDate, parseCalendarDate } from "../time.js";
|
|
48
|
+
import { readRecencyAsk } from "./recency-ask.js";
|
|
49
|
+
|
|
50
|
+
/** Days a fuzzy window (a week, a month, part of a month) widens on each side. */
|
|
51
|
+
export const FUZZY_STRETCH_DAYS = 2;
|
|
52
|
+
/** Days a near window ("3 days ago", "the other day") widens on each side. */
|
|
53
|
+
export const NEAR_STRETCH_DAYS = 1;
|
|
54
|
+
|
|
55
|
+
/** The first day of a window with no start ("before 7/22"): earlier than any date a row holds. */
|
|
56
|
+
export const OPEN_START = "0001-01-01";
|
|
57
|
+
/** The last day of a window with no end ("after 7/22"): later than any date a row holds. */
|
|
58
|
+
export const OPEN_END = "9999-12-31";
|
|
59
|
+
|
|
60
|
+
/** A stretch of calendar days, `YYYY-MM-DD`, inclusive. */
|
|
61
|
+
export interface DayWindow {
|
|
62
|
+
readonly from: string;
|
|
63
|
+
readonly to: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type TimeAnchor =
|
|
67
|
+
/** An event the question names: the caller searches the phrase and takes its date. */
|
|
68
|
+
| { readonly kind: "event"; readonly phrase: string }
|
|
69
|
+
/** The most recent session (here, when the caller knows where "here" is). */
|
|
70
|
+
| { readonly kind: "session" };
|
|
71
|
+
|
|
72
|
+
export interface TimeAsk {
|
|
73
|
+
/** The words that asked, as found in the question. */
|
|
74
|
+
readonly cue: string;
|
|
75
|
+
/** The window as asked, before the stretch. Null for an anchor (the caller resolves it). */
|
|
76
|
+
readonly said: DayWindow | null;
|
|
77
|
+
/** The window that filters: `said` widened by `stretch` days each side. */
|
|
78
|
+
readonly window: DayWindow | null;
|
|
79
|
+
/** Days each side; 0 is exact. An anchor's stretch applies once it is resolved. */
|
|
80
|
+
readonly stretch: number;
|
|
81
|
+
/** A time of day, as `YYYY-MM-DD HH:MM` bounds, when the question named one. */
|
|
82
|
+
readonly clock: { readonly from: string; readonly to: string } | null;
|
|
83
|
+
readonly anchor: TimeAnchor | null;
|
|
84
|
+
/** The question with the time words taken out. */
|
|
85
|
+
readonly rest: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const MONTH_NAMES = [
|
|
89
|
+
["january", "jan"],
|
|
90
|
+
["february", "feb"],
|
|
91
|
+
["march", "mar"],
|
|
92
|
+
["april", "apr"],
|
|
93
|
+
["may"],
|
|
94
|
+
["june", "jun"],
|
|
95
|
+
["july", "jul"],
|
|
96
|
+
["august", "aug"],
|
|
97
|
+
["september", "sept", "sep"],
|
|
98
|
+
["october", "oct"],
|
|
99
|
+
["november", "nov"],
|
|
100
|
+
["december", "dec"],
|
|
101
|
+
] as const;
|
|
102
|
+
|
|
103
|
+
const MONTH_ALT = MONTH_NAMES.flat().sort((a, b) => b.length - a.length).join("|");
|
|
104
|
+
|
|
105
|
+
/** Sunday first, as `daysBetween("1970-01-04", day) % 7` counts (that day was a Sunday). */
|
|
106
|
+
const WEEKDAY_NAMES = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] as const;
|
|
107
|
+
|
|
108
|
+
/** The words that bound a date in front of it, longest first ("up until" before "until"). */
|
|
109
|
+
const BOUND_ALT = "prior to|up until|up to|before|after|since|until|till|by";
|
|
110
|
+
type Bound = "before" | "after" | "since" | "through";
|
|
111
|
+
|
|
112
|
+
const NUMBER_WORDS: Readonly<Record<string, number>> = {
|
|
113
|
+
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
|
+
eleven: 11, twelve: 12, couple: 2, "a couple": 2, "a couple of": 2, few: 3, "a few": 3,
|
|
115
|
+
};
|
|
116
|
+
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";
|
|
117
|
+
|
|
118
|
+
/** Words that end an event phrase: what follows is the question, not the event. */
|
|
119
|
+
const PHRASE_STOP = new Set([
|
|
120
|
+
"what", "when", "where", "who", "why", "how", "which", "did", "do", "does", "was", "were", "is", "are", "we",
|
|
121
|
+
"i", "you", "he", "she", "they", "have", "had", "has", "and", "or", "but", "so",
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
/** Event "phrases" that are not events: time words a caller cannot search. */
|
|
125
|
+
const NOT_EVENTS = new Set([
|
|
126
|
+
"then", "time", "that time", "now", "noon", "midnight", "the time", "this time", "that", "same time",
|
|
127
|
+
// A stretch of time, not an event to search for ("during the week", review of #323).
|
|
128
|
+
"day", "days", "week", "weeks", "weekend", "month", "months", "year", "morning", "afternoon", "evening", "night",
|
|
129
|
+
]);
|
|
130
|
+
|
|
131
|
+
const SESSION_PHRASES: readonly string[] = [
|
|
132
|
+
"where did we leave off",
|
|
133
|
+
"where we left off",
|
|
134
|
+
"where were we",
|
|
135
|
+
"pick up where",
|
|
136
|
+
"left off",
|
|
137
|
+
"leave off",
|
|
138
|
+
"our most recent session",
|
|
139
|
+
"most recent session",
|
|
140
|
+
"our last session",
|
|
141
|
+
"last session",
|
|
142
|
+
"previous session",
|
|
143
|
+
"earlier session",
|
|
144
|
+
"our last conversation",
|
|
145
|
+
"last conversation",
|
|
146
|
+
"previous conversation",
|
|
147
|
+
"last chat",
|
|
148
|
+
"last time",
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
function monthOf(word: string): number | null {
|
|
152
|
+
const w = word.toLowerCase().replace(/\.$/, "");
|
|
153
|
+
const i = MONTH_NAMES.findIndex((names) => (names as readonly string[]).includes(w));
|
|
154
|
+
return i < 0 ? null : i + 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function numberOf(word: string): number | null {
|
|
158
|
+
const w = word.toLowerCase().trim();
|
|
159
|
+
if (/^\d+$/.test(w)) return Number(w);
|
|
160
|
+
return NUMBER_WORDS[w] ?? null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const pad = (n: number): string => String(n).padStart(2, "0");
|
|
164
|
+
|
|
165
|
+
function lastDayOf(year: number, month: number): string {
|
|
166
|
+
return parseCalendarDate(`${String(year)}-${pad(month)}`)?.last ?? `${String(year)}-${pad(month)}-28`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Monday of the week `ymd` falls in. 1970-01-05 was a Monday. */
|
|
170
|
+
function mondayOf(ymd: string): string {
|
|
171
|
+
const since = daysBetween("1970-01-05", ymd);
|
|
172
|
+
return addDays(ymd, -(((since % 7) + 7) % 7));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The most recent `weekday` (0 = Sunday) strictly before `today`: a week back when today is one. */
|
|
176
|
+
function lastWeekday(today: string, weekday: number): string {
|
|
177
|
+
const todays = ((daysBetween("1970-01-04", today) % 7) + 7) % 7;
|
|
178
|
+
const back = (todays - weekday + 7) % 7;
|
|
179
|
+
return addDays(today, -(back === 0 ? 7 : back));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function stretched(said: DayWindow, days: number): DayWindow {
|
|
183
|
+
if (days <= 0) return said;
|
|
184
|
+
// An open end stays open: there is nothing past "every day before" to widen into.
|
|
185
|
+
return {
|
|
186
|
+
from: said.from === OPEN_START ? OPEN_START : addDays(said.from, -days),
|
|
187
|
+
to: said.to === OPEN_END ? OPEN_END : addDays(said.to, days),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The word in front of a date that bounds it — "before 7/22", "since the
|
|
193
|
+
* 2026-09" — and the phrase through the date as written, to take out of the
|
|
194
|
+
* question whole. Null when the date stands alone ("on 7/22", "7/22").
|
|
195
|
+
*
|
|
196
|
+
* `event` when the date names a thing that happened on it rather than a
|
|
197
|
+
* cutoff: "before the 7/22 flight", "after the July 22 launch" (a "the" in
|
|
198
|
+
* front and a word after it that is not the question going on), "after July
|
|
199
|
+
* 22's standup", "after last Saturday's party" (review of #338, 2026-10-09).
|
|
200
|
+
* "After the 4th of July we sailed" is still a cutoff.
|
|
201
|
+
*/
|
|
202
|
+
function boundOf(text: string, found: string): { bound: Bound; word: string; phrase: string; event: { cue: string; date: string } | null } | null {
|
|
203
|
+
const m = new RegExp(`\\b(${BOUND_ALT})\\s+(the\\s+)?${escape(found)}(['’]s\\b)?`, "i").exec(text);
|
|
204
|
+
if (m === null) return null;
|
|
205
|
+
const word = (m[1] as string).toLowerCase().replace(/\s+/g, " ");
|
|
206
|
+
const bound: Bound =
|
|
207
|
+
word === "before" || word === "prior to" ? "before" : word === "after" ? "after" : word === "since" ? "since" : "through";
|
|
208
|
+
const next = /^\s+([a-z]+)/i.exec(text.slice(m.index + m[0].length))?.[1];
|
|
209
|
+
const possessive = m[3] !== undefined || /['’]s$/i.test(found);
|
|
210
|
+
const named = m[2] !== undefined && next !== undefined && !PHRASE_STOP.has(next.toLowerCase());
|
|
211
|
+
const date = `${found}${m[3] ?? ""}`;
|
|
212
|
+
return { bound, word, phrase: m[0], event: possessive || named ? { cue: `${word} ${m[2] !== undefined ? "the " : ""}${date}`, date } : null };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A date read off the question — its first and last day, and its stretch
|
|
217
|
+
* standing alone — asked as a whole or bounded by the word in front of it.
|
|
218
|
+
* `cue` is how the header names it, when that is not the text as found.
|
|
219
|
+
*/
|
|
220
|
+
function dated(text: string, found: string, first: string, last: string, stretch: number, today: string, cue = found): TimeAsk {
|
|
221
|
+
const b = boundOf(text, found);
|
|
222
|
+
if (b === null) return ask(cue, { from: first, to: last }, stretch, without(text, found));
|
|
223
|
+
if (b.event !== null) {
|
|
224
|
+
// The date names a thing on that day ("before the 7/22 flight"): the bound
|
|
225
|
+
// keeps that day, where the thing happened, and only the date leaves the
|
|
226
|
+
// question. A cutoff past it would hide the very day asked about.
|
|
227
|
+
const said: DayWindow =
|
|
228
|
+
b.bound === "since" ? { from: first, to: today } : b.bound === "after" ? { from: first, to: OPEN_END } : { from: OPEN_START, to: last };
|
|
229
|
+
return ask(b.event.cue, said, b.bound === "since" ? stretch : 0, without(text, b.event.date));
|
|
230
|
+
}
|
|
231
|
+
const said: DayWindow =
|
|
232
|
+
b.bound === "since"
|
|
233
|
+
? { from: first, to: today }
|
|
234
|
+
: b.bound === "before"
|
|
235
|
+
? { from: OPEN_START, to: addDays(first, -1) }
|
|
236
|
+
: b.bound === "after"
|
|
237
|
+
? { from: addDays(last, 1), to: OPEN_END }
|
|
238
|
+
: { from: OPEN_START, to: last };
|
|
239
|
+
// "since" keeps the stretch it always had; a cutoff the person named is exact.
|
|
240
|
+
return ask(`${b.word} ${cue}`, said, b.bound === "since" ? stretch : 0, without(text, b.phrase));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** A month named without a year: this year's when it has begun, else last year's. */
|
|
244
|
+
function yearFor(month: number, today: string): number {
|
|
245
|
+
const [y, m] = today.split("-").map(Number) as [number, number];
|
|
246
|
+
return month <= m ? y : y - 1;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Remove `found` (and a preposition just before it) from `text`, once. */
|
|
250
|
+
function without(text: string, found: string): string {
|
|
251
|
+
const at = text.toLowerCase().indexOf(found.toLowerCase());
|
|
252
|
+
if (at < 0) return text;
|
|
253
|
+
let start = at;
|
|
254
|
+
const before = text.slice(0, at);
|
|
255
|
+
const prep = /\b(?:on|in|from|since|around|during|at|of|over|for)\s+$/i.exec(before);
|
|
256
|
+
if (prep !== null) start = at - prep[0].length;
|
|
257
|
+
return `${text.slice(0, start)} ${text.slice(at + found.length)}`.replace(/\s+/g, " ").trim();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function ask(
|
|
261
|
+
cue: string,
|
|
262
|
+
said: DayWindow | null,
|
|
263
|
+
stretch: number,
|
|
264
|
+
rest: string,
|
|
265
|
+
extra: { clock?: TimeAsk["clock"]; anchor?: TimeAnchor | null } = {},
|
|
266
|
+
): TimeAsk {
|
|
267
|
+
return {
|
|
268
|
+
cue,
|
|
269
|
+
said,
|
|
270
|
+
window: said === null ? null : stretched(said, stretch),
|
|
271
|
+
stretch,
|
|
272
|
+
clock: extra.clock ?? null,
|
|
273
|
+
anchor: extra.anchor ?? null,
|
|
274
|
+
rest,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* DOES THIS QUESTION NAME A TIME — and if so, which window, how far it
|
|
280
|
+
* stretches, and what is left of the question without it? Null when it names
|
|
281
|
+
* none. Pure.
|
|
282
|
+
*/
|
|
283
|
+
export function readTimeAsk(text: string, clock: { now: number; zone: string }): TimeAsk | null {
|
|
284
|
+
const today = localDate(clock.now, clock.zone);
|
|
285
|
+
const lower = text.toLowerCase().replace(/[’]/g, "'");
|
|
286
|
+
|
|
287
|
+
// ── an event anchor: "around the cut-over", "during the release" ─────────
|
|
288
|
+
// An article is asked for ("around THE cut-over"): "questions around pricing"
|
|
289
|
+
// is about pricing, not a time.
|
|
290
|
+
const event = /\b(around|during|at the time of)\s+((?:the|our|that|my)\s+(?!\d)[^?.!,;:]+)/i.exec(text);
|
|
291
|
+
if (event !== null) {
|
|
292
|
+
const words = (event[2] ?? "").trim().split(/\s+/);
|
|
293
|
+
const kept: string[] = [];
|
|
294
|
+
for (const w of words) {
|
|
295
|
+
if (PHRASE_STOP.has(w.toLowerCase())) break;
|
|
296
|
+
kept.push(w);
|
|
297
|
+
if (kept.length >= 6) break;
|
|
298
|
+
}
|
|
299
|
+
const phrase = kept.join(" ").replace(/^(the|a|an|our|my|that|this)\s+/i, "").trim();
|
|
300
|
+
if (phrase.length >= 2 && !NOT_EVENTS.has(phrase.toLowerCase()) && monthOf(phrase) === null && !/^(today|yesterday|last|this|next|early|mid|late)\b/i.test(phrase)) {
|
|
301
|
+
const said = `${event[1] as string} ${kept.join(" ")}`;
|
|
302
|
+
return ask(said.trim(), null, FUZZY_STRETCH_DAYS, without(text, said.trim()), { anchor: { kind: "event", phrase } });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// ── the last session ─────────────────────────────────────────────────────
|
|
307
|
+
const plain = ` ${lower.replace(/'/g, "").replace(/[^a-z0-9]+/g, " ").trim()} `;
|
|
308
|
+
const session = SESSION_PHRASES.find((p) => plain.includes(` ${p} `));
|
|
309
|
+
if (session !== undefined) {
|
|
310
|
+
return ask(session, null, 0, removeWords(text, session), { anchor: { kind: "session" } });
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// ── explicit dates ───────────────────────────────────────────────────────
|
|
314
|
+
const iso = /\b(\d{4})-(\d{2})(?:-(\d{2}))?\b/.exec(text);
|
|
315
|
+
if (iso !== null) {
|
|
316
|
+
const found = iso[0];
|
|
317
|
+
const parsed = parseCalendarDate(found);
|
|
318
|
+
if (parsed !== null) {
|
|
319
|
+
return dated(text, found, parsed.first, parsed.last, parsed.precision === "day" ? 0 : FUZZY_STRETCH_DAYS, today);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// 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);
|
|
324
|
+
if (short !== null) {
|
|
325
|
+
const m = Number(short[1]);
|
|
326
|
+
const d = Number(short[2]);
|
|
327
|
+
const y = short[3] !== undefined ? Number(short[3]) : m >= 1 && m <= 12 ? yearFor(m, today) : 0;
|
|
328
|
+
const day = m >= 1 && m <= 12 ? `${String(y).padStart(4, "0")}-${pad(m)}-${pad(d)}` : null;
|
|
329
|
+
if (day !== null && parseCalendarDate(day)?.precision === "day") {
|
|
330
|
+
return dated(text, short[0], day, day, 0, today);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const named = new RegExp(
|
|
334
|
+
`\\b(${MONTH_ALT})\\.?\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b(?:,?\\s+(\\d{4})\\b)?|\\b(\\d{1,2})(?:st|nd|rd|th)?\\s+(?:of\\s+)?(${MONTH_ALT})\\b(?:,?\\s+(\\d{4})\\b)?`,
|
|
335
|
+
"i",
|
|
336
|
+
).exec(text);
|
|
337
|
+
if (named !== null) {
|
|
338
|
+
const month = monthOf((named[1] ?? named[5]) as string);
|
|
339
|
+
const d = Number(named[2] ?? named[4]);
|
|
340
|
+
const year = named[3] ?? named[6];
|
|
341
|
+
if (month !== null) {
|
|
342
|
+
const day = `${String(year !== undefined ? Number(year) : yearFor(month, today)).padStart(4, "0")}-${pad(month)}-${pad(d)}`;
|
|
343
|
+
if (parseCalendarDate(day)?.precision === "day") {
|
|
344
|
+
return dated(text, named[0], day, day, 0, today);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ── months ───────────────────────────────────────────────────────────────
|
|
350
|
+
const [ty, tm] = today.split("-").map(Number) as [number, number];
|
|
351
|
+
if (/\blast month\b/i.test(text)) {
|
|
352
|
+
const y = tm === 1 ? ty - 1 : ty;
|
|
353
|
+
const m = tm === 1 ? 12 : tm - 1;
|
|
354
|
+
return ask("last month", { from: `${String(y)}-${pad(m)}-01`, to: lastDayOf(y, m) }, FUZZY_STRETCH_DAYS, without(text, "last month"));
|
|
355
|
+
}
|
|
356
|
+
if (/\bthis month\b/i.test(text)) {
|
|
357
|
+
return ask("this month", { from: `${String(ty)}-${pad(tm)}-01`, to: today }, FUZZY_STRETCH_DAYS, without(text, "this month"));
|
|
358
|
+
}
|
|
359
|
+
const part = new RegExp(`\\b(early|mid|late|the start of|the beginning of|the end of|the middle of)[\\s-]+(${MONTH_ALT})\\b`, "i").exec(text);
|
|
360
|
+
if (part !== null) {
|
|
361
|
+
const month = monthOf(part[2] as string);
|
|
362
|
+
if (month !== null) {
|
|
363
|
+
const y = yearFor(month, today);
|
|
364
|
+
const last = lastDayOf(y, month);
|
|
365
|
+
const which = (part[1] as string).toLowerCase();
|
|
366
|
+
const first = `${String(y)}-${pad(month)}-01`;
|
|
367
|
+
const said =
|
|
368
|
+
which === "early" || which === "the start of" || which === "the beginning of"
|
|
369
|
+
? { from: first, to: `${String(y)}-${pad(month)}-10` }
|
|
370
|
+
: which === "mid" || which === "the middle of"
|
|
371
|
+
? { from: `${String(y)}-${pad(month)}-11`, to: `${String(y)}-${pad(month)}-20` }
|
|
372
|
+
: { from: `${String(y)}-${pad(month)}-21`, to: last };
|
|
373
|
+
return ask(part[0], said, FUZZY_STRETCH_DAYS, without(text, part[0]));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const inMonth = new RegExp(`\\b(in|during|since|through|throughout|over)\\s+(${MONTH_ALT})\\b(?:\\s+(\\d{4}))?|\\b(${MONTH_ALT})\\s+(\\d{4})\\b`, "i").exec(text);
|
|
377
|
+
if (inMonth !== null) {
|
|
378
|
+
const name = (inMonth[2] ?? inMonth[4]) as string;
|
|
379
|
+
const month = monthOf(name);
|
|
380
|
+
// "may" as a month only with a year or "in May": "in may" is still ambiguous ("in may be"), so a capital is asked for.
|
|
381
|
+
const mayOk = name.toLowerCase() !== "may" || /\bMay\b/.test(inMonth[0]);
|
|
382
|
+
if (month !== null && mayOk) {
|
|
383
|
+
const yearText = inMonth[3] ?? inMonth[5];
|
|
384
|
+
const y = yearText !== undefined ? Number(yearText) : yearFor(month, today);
|
|
385
|
+
const first = `${String(y)}-${pad(month)}-01`;
|
|
386
|
+
const isSince = (inMonth[1] ?? "").toLowerCase() === "since";
|
|
387
|
+
const found = inMonth[1] !== undefined ? inMonth[0].slice(inMonth[1].length).trim() : inMonth[0];
|
|
388
|
+
return ask(
|
|
389
|
+
inMonth[0].trim(),
|
|
390
|
+
isSince ? { from: first, to: today } : { from: first, to: lastDayOf(y, month) },
|
|
391
|
+
FUZZY_STRETCH_DAYS,
|
|
392
|
+
without(text, found),
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ── weeks ────────────────────────────────────────────────────────────────
|
|
398
|
+
if (/\blast week\b/i.test(text)) {
|
|
399
|
+
const monday = addDays(mondayOf(today), -7);
|
|
400
|
+
return ask("last week", { from: monday, to: addDays(monday, 6) }, FUZZY_STRETCH_DAYS, without(text, "last week"));
|
|
401
|
+
}
|
|
402
|
+
if (/\bthis week\b/i.test(text)) {
|
|
403
|
+
return ask("this week", { from: mondayOf(today), to: today }, FUZZY_STRETCH_DAYS, without(text, "this week"));
|
|
404
|
+
}
|
|
405
|
+
const pastWeek = /\b(the\s+)?(past|last)\s+(7 days|seven days|week)\b/i.exec(text);
|
|
406
|
+
if (pastWeek !== null) {
|
|
407
|
+
return ask(pastWeek[0], { from: addDays(today, -6), to: today }, 0, without(text, pastWeek[0]));
|
|
408
|
+
}
|
|
409
|
+
const weeksAgo = new RegExp(`\\b(${NUMBER_ALT})\\s+weeks?\\s+ago\\b`, "i").exec(text);
|
|
410
|
+
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]));
|
|
414
|
+
}
|
|
415
|
+
const fewWeeks = /\b(the\s+)?(past|last)\s+(few|couple of|two|three)\s+weeks\b/i.exec(text);
|
|
416
|
+
if (fewWeeks !== null) {
|
|
417
|
+
const n = numberOf(fewWeeks[3] as string) ?? 3;
|
|
418
|
+
return ask(fewWeeks[0], { from: addDays(today, -7 * n + 1), to: today }, 0, without(text, fewWeeks[0]));
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// ── days ─────────────────────────────────────────────────────────────────
|
|
422
|
+
// "Last Saturday": the most recent one before today — a week back when
|
|
423
|
+
// today is a Saturday — and exact, as a named day is; a word in front bounds
|
|
424
|
+
// it as it bounds a date ("since last Saturday"). Not "the last Saturday",
|
|
425
|
+
// which is the last of something else ("of June") (2026-10-09).
|
|
426
|
+
const weekday = new RegExp(`(?<!\\bthe\\s)\\b(?:last|this past)\\s+(${WEEKDAY_NAMES.join("|")})\\b(?:['’]s\\b)?`, "i").exec(text);
|
|
427
|
+
if (weekday !== null) {
|
|
428
|
+
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, ""));
|
|
430
|
+
}
|
|
431
|
+
// Before "yesterday" is read on its own (review of #323).
|
|
432
|
+
const dayBefore = /\bthe day before yesterday\b/i.exec(text);
|
|
433
|
+
if (dayBefore !== null) {
|
|
434
|
+
const day = addDays(today, -2);
|
|
435
|
+
return ask(dayBefore[0], { from: day, to: day }, 0, without(text, dayBefore[0]));
|
|
436
|
+
}
|
|
437
|
+
const daysAgo = new RegExp(`\\b(${NUMBER_ALT})\\s+days?\\s+ago\\b`, "i").exec(text);
|
|
438
|
+
if (daysAgo !== null) {
|
|
439
|
+
const word = (daysAgo[1] as string).toLowerCase();
|
|
440
|
+
if (word === "few" || word === "a few" || word === "couple" || word === "a couple" || word === "a couple of") {
|
|
441
|
+
return ask(daysAgo[0], { from: addDays(today, -5), to: addDays(today, -2) }, NEAR_STRETCH_DAYS, without(text, daysAgo[0]));
|
|
442
|
+
}
|
|
443
|
+
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]));
|
|
446
|
+
}
|
|
447
|
+
if (/\bthe other day\b/i.test(text)) {
|
|
448
|
+
return ask("the other day", { from: addDays(today, -5), to: addDays(today, -2) }, NEAR_STRETCH_DAYS, without(text, "the other day"));
|
|
449
|
+
}
|
|
450
|
+
const pastDays = new RegExp(`\\b(the\\s+)?(past|last)\\s+(${NUMBER_ALT})\\s+days\\b`, "i").exec(text);
|
|
451
|
+
if (pastDays !== null) {
|
|
452
|
+
const n = Math.max(1, numberOf(pastDays[3] as string) ?? 3);
|
|
453
|
+
return ask(pastDays[0], { from: addDays(today, -(n - 1)), to: today }, 0, without(text, pastDays[0]));
|
|
454
|
+
}
|
|
455
|
+
if (/\b(recently|lately)\b/i.test(text)) {
|
|
456
|
+
const found = /\b(recently|lately)\b/i.exec(text)?.[0] ?? "recently";
|
|
457
|
+
return ask(found, { from: addDays(today, -6), to: today }, 0, without(text, found));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// ── a named day or a clock: `recency-ask.ts`'s reading ───────────────────
|
|
461
|
+
const recency = readRecencyAsk(text, clock);
|
|
462
|
+
if (recency !== null && recency.window !== null) {
|
|
463
|
+
const from = recency.window.from.slice(0, 10);
|
|
464
|
+
const to = recency.window.to.slice(0, 10);
|
|
465
|
+
const cue = recency.cue;
|
|
466
|
+
const rest = cue === "a clock time" ? text : removeWords(text, cue);
|
|
467
|
+
// A whole day is a day; a part of one (a morning, a clock time) filters by the clock too.
|
|
468
|
+
const whole = recency.window.from.endsWith("00:00") && recency.window.to.endsWith("23:59");
|
|
469
|
+
return ask(cue, { from, to }, 0, rest, whole ? {} : { clock: { from: recency.window.from, to: recency.window.to } });
|
|
470
|
+
}
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function escape(s: string): string {
|
|
475
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** Take a phrase matched on plain words out of the original text, as words. */
|
|
479
|
+
function removeWords(text: string, phrase: string): string {
|
|
480
|
+
const pattern = phrase
|
|
481
|
+
.split(" ")
|
|
482
|
+
.map((w) => escape(w).split("").join("['’]?"))
|
|
483
|
+
.join("[^a-z0-9]+");
|
|
484
|
+
const re = new RegExp(`\\b${pattern}\\b`, "i");
|
|
485
|
+
const m = re.exec(text);
|
|
486
|
+
return m === null ? text : without(text, m[0]);
|
|
487
|
+
}
|
|
@@ -212,7 +212,10 @@ INTERFACE-GAPS §2a; this module still never gates and never reads them).
|
|
|
212
212
|
miss falls back to **content matching** against candidate memories — score and margin
|
|
213
213
|
both required, ambiguity refuses, the author's hint is a tiebreak inside the margin and
|
|
214
214
|
can never defeat a refusal, and score/margin/method are logged as provenance
|
|
215
|
-
(scar §2.5). A miss costs nothing durable: the memory still lands.
|
|
215
|
+
(scar §2.5). A miss costs nothing durable: the memory still lands. An id that RESOLVES
|
|
216
|
+
is an address, not yet a licence: whether a `changed` or `corrected` there may move the
|
|
217
|
+
memory it names is the update guard's call, made after this resolution
|
|
218
|
+
(2026-10-09, `schemas/CONTRACT.md` §5 1b).
|
|
216
219
|
11. **[A] The ask's wording is load-bearing and is part of the spec** — first person, the
|
|
217
220
|
author's own voice, what happened and what mattered, how it felt, what was learned
|
|
218
221
|
about the person and about oneself. It sanctions honesty about a routine stretch and
|
|
@@ -297,7 +297,15 @@ proposal and the memory stay the depositor's. The next-session write-up's door p
|
|
|
297
297
|
`false` on an earlier part and the ended session on the last; the instance-level
|
|
298
298
|
shadowing of `SpanBuffer#claimCoverage` it replaced is gone (NOTES §17).
|
|
299
299
|
|
|
300
|
-
## 16. `HeldSession` does not say when a session last answered, or last spoke
|
|
300
|
+
## 16. `HeldSession` does not say when a session last answered, or last spoke — CLOSED 2026-09-30 by replacement, #289 (noted 2026-10-09)
|
|
301
|
+
|
|
302
|
+
**Closed by replacement** (#289, `fc665c2`, merged 2026-09-30): the asked / answered
|
|
303
|
+
predicate and `sessions.ts#openAndAnswered` are gone. What a session owes is
|
|
304
|
+
`core/coverage/`'s ledger (`HeldSession.owes` carries it), which knows per piece whether a
|
|
305
|
+
claim covers it, so words said after an answer are an unwritten stretch with no
|
|
306
|
+
`lastAnswerAt` needed (claude-code INTERFACE-GAPS §17, closed the same way).
|
|
307
|
+
|
|
308
|
+
*The entry as filed, for the record:*
|
|
301
309
|
|
|
302
310
|
**Owner:** `remember/owes.ts#planRetention`. Filed 2026-09-23 (C2 re-review m-E).
|
|
303
311
|
`planRetention` computes the time of every answer it counts (proposal times, handoff rows,
|
|
@@ -632,3 +632,11 @@ in a session not at work, not lapsed. `HeldSession.owes` is that rule; `small` r
|
|
|
632
632
|
and a chapter now claim (`coverage/#claimUnwritten`); a handoff alone does not.
|
|
633
633
|
`RetentionSources` is the host's evidence and the store's zone, nothing else;
|
|
634
634
|
`retention.ts` did not change. Why, and the choices: `core/coverage/NOTES.md`.
|
|
635
|
+
|
|
636
|
+
## 2026-10-03 — `Proposal.facts` (schema v12)
|
|
637
|
+
|
|
638
|
+
The writer's three fields (`occurredOn`, `saidBy`, `status`) ride the proposal as `facts`,
|
|
639
|
+
set by `Counterpart#deposit` from what the door read — not by intake, and not in
|
|
640
|
+
`DRAFT_FIELDS`. Intake refuses an unreadable `eventDate`; these are loose-first (an
|
|
641
|
+
unreadable one is dropped with a note at the door and the memory still mints), so they are
|
|
642
|
+
read before intake, the way `about` and `feelings` are. `mint.ts` writes them to the row.
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
import { SETTLE_HOWS } from "../types.js";
|
|
23
23
|
import type { Kind, Salience, SettleHow } from "../types.js";
|
|
24
24
|
import { hashText } from "../store/prose.js";
|
|
25
|
-
import {
|
|
25
|
+
import type { WriteFacts } from "../store/index.js";
|
|
26
|
+
import { isDay, isRecurrence, parseCalendarDate } from "../time.js";
|
|
27
|
+
import type { Recurrence } from "../time.js";
|
|
26
28
|
import { randomBytes } from "node:crypto";
|
|
27
29
|
|
|
28
30
|
// TYPE-ONLY, and the only edge this module has to `encode/`. The gate itself
|
|
@@ -81,6 +83,13 @@ export interface ProposalDraft {
|
|
|
81
83
|
/** Plain or quiet (`prospective/` `CUE_MODE_META`). Only meaningful beside an
|
|
82
84
|
* `eventDate`; without one it is dropped and counted. Default quiet. */
|
|
83
85
|
remind?: "plain" | "quiet";
|
|
86
|
+
/**
|
|
87
|
+
* How often the date comes round, anchored on it (2026-10-09, `meta.recurring`):
|
|
88
|
+
* `daily | weekly | monthly | yearly`. Only a DAY repeats — beside a month,
|
|
89
|
+
* a range or a year it is malformed (`RECURRING_NEEDS_DAY`); without a date
|
|
90
|
+
* it is dropped and counted, as `remind` is.
|
|
91
|
+
*/
|
|
92
|
+
recurring?: Recurrence;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
export type ProposalSource = "session-end" | "jot";
|
|
@@ -92,6 +101,10 @@ export interface DateIntent {
|
|
|
92
101
|
readonly eventDate: "set" | "cleared" | "absent";
|
|
93
102
|
/** The `remind` the author sent, or null when none was (the draft's quiet is a default). */
|
|
94
103
|
readonly remind: "plain" | "quiet" | null;
|
|
104
|
+
/** The `recurring` the author sent (2026-10-09); `cleared` when it sent
|
|
105
|
+
* `recurring: null` (a revision's "it no longer repeats"); null when it
|
|
106
|
+
* sent nothing. */
|
|
107
|
+
readonly recurring: Recurrence | "cleared" | null;
|
|
95
108
|
}
|
|
96
109
|
|
|
97
110
|
/** What the engine mints. Memory objects only — no operations, by construction. */
|
|
@@ -119,6 +132,9 @@ export interface Proposal {
|
|
|
119
132
|
eventDate: string | null;
|
|
120
133
|
/** Plain or quiet — null exactly when `eventDate` is. */
|
|
121
134
|
remind: "plain" | "quiet" | null;
|
|
135
|
+
/** How often the date comes round (2026-10-09). Absent or null: once. Never
|
|
136
|
+
* set without a DAY `eventDate`. */
|
|
137
|
+
recurring?: Recurrence | null;
|
|
122
138
|
/**
|
|
123
139
|
* What the author SAID about the date, as opposed to what defaulted — read
|
|
124
140
|
* only when this proposal revises a memory (`updates:`), where a date the
|
|
@@ -141,6 +157,14 @@ export interface Proposal {
|
|
|
141
157
|
* `meta.reminderFrom` at the minting seam (prospective `DATE_FROM_META`).
|
|
142
158
|
*/
|
|
143
159
|
reminderFrom?: string;
|
|
160
|
+
/**
|
|
161
|
+
* v12 (2026-10-03): the writer's three fields — when it happened, who said
|
|
162
|
+
* it, what kind of thing it is — set by `Counterpart#deposit` from what the
|
|
163
|
+
* door read (never from intake: they are not draft fields, so an unreadable
|
|
164
|
+
* one is dropped with a note at the door rather than refusing the memory),
|
|
165
|
+
* with a revision's carried over. Absent on a proposal no author wrote.
|
|
166
|
+
*/
|
|
167
|
+
facts?: WriteFacts;
|
|
144
168
|
at: number;
|
|
145
169
|
day: number;
|
|
146
170
|
/** Identity for idempotency: CONTENT, not span text (§4.1 G9). */
|
|
@@ -169,6 +193,10 @@ export type MalformedReason =
|
|
|
169
193
|
| "EVENT_DATE_UNREADABLE"
|
|
170
194
|
/** `remind` is not `plain` or `quiet`. */
|
|
171
195
|
| "REMIND_UNKNOWN"
|
|
196
|
+
/** `recurring` is not `daily`, `weekly`, `monthly` or `yearly` (2026-10-09). */
|
|
197
|
+
| "RECURRING_UNKNOWN"
|
|
198
|
+
/** `recurring` beside an `eventDate` that is not one day: only a day repeats. */
|
|
199
|
+
| "RECURRING_NEEDS_DAY"
|
|
172
200
|
/** `how` is not `changed`, `corrected` or `open`. */
|
|
173
201
|
| "HOW_UNKNOWN";
|
|
174
202
|
|
|
@@ -200,6 +228,7 @@ export const DRAFT_FIELDS = [
|
|
|
200
228
|
"unresolved",
|
|
201
229
|
"eventDate",
|
|
202
230
|
"remind",
|
|
231
|
+
"recurring",
|
|
203
232
|
] as const;
|
|
204
233
|
|
|
205
234
|
export type IntakeResult =
|
|
@@ -299,15 +328,26 @@ export function intake(raw: unknown): IntakeResult {
|
|
|
299
328
|
if (rec["remind"] !== undefined && rec["remind"] !== null) {
|
|
300
329
|
if (rec["remind"] !== "plain" && rec["remind"] !== "quiet") return bad("REMIND_UNKNOWN");
|
|
301
330
|
}
|
|
331
|
+
// HOW OFTEN IT COMES ROUND (2026-10-09): one of four words, and only beside
|
|
332
|
+
// a DAY — a month, a range or a year has no one day to come round on.
|
|
333
|
+
let recurring: Recurrence | undefined;
|
|
334
|
+
if (rec["recurring"] !== undefined && rec["recurring"] !== null) {
|
|
335
|
+
if (!isRecurrence(rec["recurring"])) return bad("RECURRING_UNKNOWN");
|
|
336
|
+
if (eventDate !== undefined && !isDay(eventDate)) return bad("RECURRING_NEEDS_DAY");
|
|
337
|
+
recurring = rec["recurring"];
|
|
338
|
+
}
|
|
302
339
|
|
|
303
340
|
const draft: ProposalDraft = { content: rec["content"] as string };
|
|
304
341
|
if (eventDate !== undefined) {
|
|
305
342
|
draft.eventDate = eventDate;
|
|
306
343
|
draft.remind = rec["remind"] === "plain" ? "plain" : "quiet";
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
//
|
|
310
|
-
dropped
|
|
344
|
+
if (recurring !== undefined) draft.recurring = recurring;
|
|
345
|
+
} else {
|
|
346
|
+
// Plain or quiet says HOW a date comes back, and `recurring` how often;
|
|
347
|
+
// with no date there is nothing to come back, so each is dropped and
|
|
348
|
+
// counted like any field with nowhere to go.
|
|
349
|
+
if (rec["remind"] !== undefined && rec["remind"] !== null) dropped.push("remind");
|
|
350
|
+
if (recurring !== undefined) dropped.push("recurring");
|
|
311
351
|
}
|
|
312
352
|
if (rec["kind"] !== undefined) draft.kind = rec["kind"] as Kind;
|
|
313
353
|
if (typeof rec["title"] === "string") draft.title = rec["title"];
|
|
@@ -331,6 +371,7 @@ export function intake(raw: unknown): IntakeResult {
|
|
|
331
371
|
const dateIntent: DateIntent = {
|
|
332
372
|
eventDate: eventDate !== undefined ? "set" : rec["eventDate"] === null ? "cleared" : "absent",
|
|
333
373
|
remind: rec["remind"] === "plain" || rec["remind"] === "quiet" ? rec["remind"] : null,
|
|
374
|
+
recurring: recurring ?? (rec["recurring"] === null ? "cleared" : null),
|
|
334
375
|
};
|
|
335
376
|
const threadSaid = typeof rec["unresolved"] === "boolean";
|
|
336
377
|
return { ok: true, draft: draft as Required<Pick<ProposalDraft, "content">> & ProposalDraft, dropped, dateIntent, threadSaid };
|
|
@@ -649,6 +690,7 @@ export async function submitProposal(
|
|
|
649
690
|
unresolved: draft.unresolved === true,
|
|
650
691
|
eventDate: draft.eventDate ?? null,
|
|
651
692
|
remind: draft.eventDate === undefined ? null : draft.remind ?? "quiet",
|
|
693
|
+
recurring: draft.eventDate === undefined ? null : draft.recurring ?? null,
|
|
652
694
|
dateIntent: parsed.dateIntent,
|
|
653
695
|
...(parsed.threadSaid ? { threadSaid: true } : {}),
|
|
654
696
|
at: buffer.now(),
|