counterparts 0.3.39 → 0.3.41
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 +47 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/doctor-open.ts +28 -0
- package/src/adapters/claude-code/doctor.ts +5 -1
- package/src/adapters/dashboard/registries.ts +3 -0
- package/src/adapters/dashboard/web/flow.ts +2 -0
- package/src/adapters/dashboard/web/lanes.ts +1 -0
- package/src/adapters/dashboard/web/narrate.ts +19 -0
- package/src/adapters/fired.ts +1 -1
- package/src/adapters/mcp/NOTES.md +59 -0
- package/src/adapters/mcp/server-words.ts +1 -1
- package/src/adapters/mcp/server.ts +43 -17
- package/src/adapters/mcp/tools.ts +23 -5
- package/src/adapters/remote/NOTES.md +2 -1
- package/src/adapters/update-check.ts +1 -1
- package/src/core/counterpart-events.ts +5 -1
- package/src/core/counterpart.ts +70 -11
- package/src/core/dream/reflect.ts +4 -2
- package/src/core/onboarding.ts +35 -7
- package/src/core/recall/CONTRACT.md +23 -2
- package/src/core/recall/NOTES.md +101 -0
- package/src/core/recall/activate.ts +188 -31
- package/src/core/recall/gate.ts +8 -2
- package/src/core/recall/index.ts +52 -11
- package/src/core/recall/prime.ts +7 -1
- package/src/core/recall/rated.ts +1 -1
- package/src/core/recall/render.ts +15 -2
- package/src/core/recall/session.ts +8 -4
- package/src/core/recall/tunables.ts +34 -4
- package/src/core/schemas/NOTES.md +8 -0
- package/src/core/schemas/tunables.ts +6 -1
- package/src/core/self/NOTES.md +77 -0
- package/src/core/self/briefing-room.ts +88 -12
- package/src/core/self/briefing.ts +114 -15
- package/src/core/self/identity.ts +40 -8
- package/src/core/self/index.ts +56 -23
- package/src/core/self/tunables.ts +12 -2
- package/src/core/self/work.ts +20 -0
- package/src/core/store/index.ts +4 -3
- package/src/core/store/reads-memories.ts +37 -7
|
@@ -56,6 +56,8 @@ import type { SelfTunables } from "./tunables.js";
|
|
|
56
56
|
import type { Kept, RescueCtx, Rescued } from "./briefing-room.js";
|
|
57
57
|
import {
|
|
58
58
|
foldParts,
|
|
59
|
+
owedParked,
|
|
60
|
+
withoutParked,
|
|
59
61
|
withoutNearby,
|
|
60
62
|
arrivingHead,
|
|
61
63
|
arrivingNear,
|
|
@@ -525,7 +527,7 @@ export const STILL_OPEN_HANDLE = "still open";
|
|
|
525
527
|
* The line it replaces — `(96 more still open, 15 untouched for 2+ weeks;
|
|
526
528
|
* recall ids (the first 5): mem_…×5)` — read as guilt, and five bare ids said
|
|
527
529
|
* nothing of what they were. Its "untouched" count was a third rule beside
|
|
528
|
-
* the carry (`identity.ts#openCarry`: 21 lived days, a glimpse is not a
|
|
530
|
+
* the carry (`identity.ts#openCarry`: 21 lived days then, 14 since P2; a glimpse is not a
|
|
529
531
|
* touch) and the order (`STILL_OPEN_STALE_DAYS`: 14, born or used), so it is
|
|
530
532
|
* dropped rather than realigned; the order still puts the weeks-old last.
|
|
531
533
|
*
|
|
@@ -550,11 +552,62 @@ export const OPEN_TAIL_WORDS = `kept quietly; recall "${STILL_OPEN_HANDLE}" list
|
|
|
550
552
|
/** "Still open"'s tail words from #623 (2026-10-25, morning), read back off a bundle stored with them. */
|
|
551
553
|
export const OPEN_TAIL_WORDS_BEFORE = "kept quietly; recall finds one by what it's about";
|
|
552
554
|
|
|
555
|
+
/**
|
|
556
|
+
* WHAT "STILL OPEN" PARKED, COUNTED ON ITS TAIL (P2, 2026-10-28; roadmap
|
|
557
|
+
* 10-28, lightly held): `(5 more open, kept quietly; recall "still open"
|
|
558
|
+
* lists them) · 41 parked`. A parked thread (untouched `OPEN_CARRY_DAYS`
|
|
559
|
+
* lived days, `identity.ts#openCarry`) is in no lane and not in the "more"
|
|
560
|
+
* count; this says how many there are, after the paren so `countedLanes`
|
|
561
|
+
* reads the count as before, and the handle the tail names lists them,
|
|
562
|
+
* marked. It rides on the lane's own count line — the "more" line, the
|
|
563
|
+
* collapsed one, or the lane's part of the folded line (`foldedLine`).
|
|
564
|
+
*
|
|
565
|
+
* AND A LANE WITH NO COUNT LINE STILL SAYS IT (P2b, 2026-10-28; the brief:
|
|
566
|
+
* parked items are counted, not vanished, and a clean list for a new user in
|
|
567
|
+
* week 3 is its main aim): a lane that lists all it carries gets one short
|
|
568
|
+
* line under its items, `(3 parked; recall "still open" lists them)`, and a
|
|
569
|
+
* wake that carries no open item at all gets the lane as one line, `Still
|
|
570
|
+
* open: nothing current · 3 parked (recall "still open" lists them)`
|
|
571
|
+
* (`parkedLine`). Before this, on day 40 a store with 3 parked items and
|
|
572
|
+
* nothing carried woke with no word of them. Reserved like a lane's count
|
|
573
|
+
* line (`briefing-room.ts#pinnedLines`), never a second count: the lane's own
|
|
574
|
+
* line carries the tail when it has one. Nothing when none is parked.
|
|
575
|
+
* Revert: `parkedTail` returns "" and `parkedLine` null.
|
|
576
|
+
*/
|
|
577
|
+
export const PARKED_WORDS = "parked";
|
|
578
|
+
|
|
579
|
+
/** ` · 41 parked`, or nothing for none. */
|
|
580
|
+
export function parkedTail(parked: number | undefined): string {
|
|
581
|
+
return parked === undefined || !(parked >= 1) ? "" : ` · ${String(Math.floor(parked))} ${PARKED_WORDS}`;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** "Still open" carrying nothing, said in its one line (`parkedLine`). */
|
|
585
|
+
export const NOTHING_CURRENT_WORDS = "nothing current";
|
|
586
|
+
|
|
587
|
+
/** Where the parked are listed, as the parked line says it. */
|
|
588
|
+
export const PARKED_HANDLE_WORDS = `recall "${STILL_OPEN_HANDLE}" lists them`;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* "Still open"'s line when the lane has no count line of its own but some
|
|
592
|
+
* are parked (P2b, `PARKED_WORDS`): under the items it lists (`listing`),
|
|
593
|
+
* `(3 parked; recall "still open" lists them)`; with none listed, the lane
|
|
594
|
+
* as one line, `Still open: nothing current · 3 parked (recall "still open"
|
|
595
|
+
* lists them)`, which `collapsedLane` reads as the lane's. Null for none.
|
|
596
|
+
*/
|
|
597
|
+
export function parkedLine(listing: boolean, parked: number | undefined): string | null {
|
|
598
|
+
if (parked === undefined || !(parked >= 1)) return null;
|
|
599
|
+
const n = String(Math.floor(parked));
|
|
600
|
+
return listing
|
|
601
|
+
? `(${n} ${PARKED_WORDS}; ${PARKED_HANDLE_WORDS})`
|
|
602
|
+
: `${laneHeading("threads")} ${NOTHING_CURRENT_WORDS}${parkedTail(parked)} (${PARKED_HANDLE_WORDS})`;
|
|
603
|
+
}
|
|
604
|
+
|
|
553
605
|
/** `(3 more might be relevant; recall ids: mem_…, mem_…, mem_…)`; for "Still
|
|
554
|
-
* open" `(56 more open, kept quietly; …)` (`OPEN_TAIL_WORDS`)
|
|
606
|
+
* open" `(56 more open, kept quietly; …)` (`OPEN_TAIL_WORDS`), and ` · N
|
|
607
|
+
* parked` after it when some are (`parkedTail`); for "Coming up"
|
|
555
608
|
* `(2 overdue, 4 more coming up; recall ids: …)` or `(2 overdue; recall ids: …)`. */
|
|
556
|
-
export function moreLine(lane: LaneName, ids: readonly string[], overdue?: readonly string[]): string {
|
|
557
|
-
if (lane === "threads") return `(${String(ids.length)} more open, ${OPEN_TAIL_WORDS})`;
|
|
609
|
+
export function moreLine(lane: LaneName, ids: readonly string[], overdue?: readonly string[], parked?: number): string {
|
|
610
|
+
if (lane === "threads") return `(${String(ids.length)} more open, ${OPEN_TAIL_WORDS})${parkedTail(parked)}`;
|
|
558
611
|
const late = overdueAmong(lane, ids, overdue);
|
|
559
612
|
if (late === 0) return `(${String(ids.length)} more ${MORE_NOUN[lane]}; ${recallIds(ids)})`;
|
|
560
613
|
const rest = ids.length - late;
|
|
@@ -579,14 +632,16 @@ const FOLD_ORDER: readonly LaneName[] = ["horizon", "threads", "identity", "craf
|
|
|
579
632
|
/** How many ids each folded lane names — fewer than its own line's five. */
|
|
580
633
|
export const FOLD_LINE_IDS = 3;
|
|
581
634
|
|
|
582
|
-
/** `More than this wake lists: 7 coming up (recall ids: mem_…, mem_…, mem_…, and 4 more); 5 might be relevant (recall ids: …)
|
|
583
|
-
|
|
635
|
+
/** `More than this wake lists: 7 coming up (recall ids: mem_…, mem_…, mem_…, and 4 more); 5 might be relevant (recall ids: …)`;
|
|
636
|
+
* "Still open"'s part ends ` · N parked` when some are (`parkedTail`; P2b,
|
|
637
|
+
* 2026-10-28 — the folded line dropped it before). */
|
|
638
|
+
export function foldedLine(lost: Partial<Record<LaneName, readonly string[]>>, parked?: number): string | null {
|
|
584
639
|
const lanes = FOLD_ORDER.filter((l) => (lost[l]?.length ?? 0) > 0);
|
|
585
640
|
if (lanes.length === 0) return null;
|
|
586
641
|
const part = (l: LaneName): string => {
|
|
587
642
|
const ids = lost[l] ?? [];
|
|
588
643
|
const shown = ids.slice(0, FOLD_LINE_IDS);
|
|
589
|
-
return `${String(ids.length)} ${MORE_NOUN[l]} (recall ids: ${shown.join(", ")}${ids.length > shown.length ? `, and ${String(ids.length - shown.length)} more` : ""})`;
|
|
644
|
+
return `${String(ids.length)} ${MORE_NOUN[l]} (recall ids: ${shown.join(", ")}${ids.length > shown.length ? `, and ${String(ids.length - shown.length)} more` : ""})${l === "threads" ? parkedTail(parked) : ""}`;
|
|
590
645
|
};
|
|
591
646
|
return `${FOLDED_WORDS} ${lanes.map(part).join("; ")}`;
|
|
592
647
|
}
|
|
@@ -612,7 +667,10 @@ export function countedLanes(text: string): Partial<Record<LaneName, number>> {
|
|
|
612
667
|
const collapsed = collapsedLane(line);
|
|
613
668
|
if (collapsed !== null) {
|
|
614
669
|
const heading = headingsOf(collapsed).find((h) => line.startsWith(`${h} `)) ?? laneHeading(collapsed);
|
|
615
|
-
|
|
670
|
+
// "Still open: nothing current · 3 parked (…)" (`parkedLine`) counts
|
|
671
|
+
// nothing the lane left out: the parked are not "more".
|
|
672
|
+
const n = /^\D*(\d+) — /.exec(line.slice(heading.length))?.[1];
|
|
673
|
+
if (n !== undefined) out[collapsed] = Number(n);
|
|
616
674
|
continue;
|
|
617
675
|
}
|
|
618
676
|
// "Still open"'s calm tail (2026-10-25): `(96 more open, kept quietly; …)`,
|
|
@@ -680,12 +738,14 @@ export function collapsedLine(lane: LaneName, ids: readonly string[], counted?:
|
|
|
680
738
|
// Those past their date said as such (review of #511): `none due today, 2 overdue`.
|
|
681
739
|
const late = none ? overdueAmong(lane, ids, counted?.horizonOverdue) : 0;
|
|
682
740
|
const why = none ? `${NONE_TODAY_WORDS}${late === 0 ? "" : `, ${String(late)} ${OVERDUE_WORD}`}` : COLLAPSED_WORDS;
|
|
683
|
-
|
|
741
|
+
// "Still open"'s parked, after the ids (P2, `parkedTail`).
|
|
742
|
+
return `${laneHeading(lane)} ${String(ids.length)} — ${why}; ${recallIds(ids)}${lane === "threads" ? parkedTail(counted?.threadsParked) : ""}`;
|
|
684
743
|
}
|
|
685
744
|
|
|
686
745
|
/** What "Coming up" counts rather than lists, as a composition's request
|
|
687
|
-
* carries it (`BriefingRequest.horizonLater`, `.horizonOverdue`)
|
|
688
|
-
|
|
746
|
+
* carries it (`BriefingRequest.horizonLater`, `.horizonOverdue`) — and
|
|
747
|
+
* what "Still open" parked (`.threadsParked`, P2). */
|
|
748
|
+
export type HorizonCounted = Pick<BriefingRequest, "horizonLater" | "horizonOverdue" | "threadsParked">;
|
|
689
749
|
|
|
690
750
|
/** The lane a collapsed line (`collapsedLine`) speaks for, or null for any other line. */
|
|
691
751
|
export function collapsedLane(line: string): LaneName | null {
|
|
@@ -693,6 +753,8 @@ export function collapsedLane(line: string): LaneName | null {
|
|
|
693
753
|
for (const heading of headingsOf(lane)) {
|
|
694
754
|
if (!line.startsWith(`${heading} `)) continue;
|
|
695
755
|
if (new RegExp(`^ \\d+ — (?:${COLLAPSED_WORDS}|${NONE_TODAY_WORDS}(?:, \\d+ ${OVERDUE_WORD})?); recall ids`).test(line.slice(heading.length))) return lane;
|
|
756
|
+
// "Still open" carrying nothing, its parked counted (`parkedLine`, P2b).
|
|
757
|
+
if (lane === "threads" && new RegExp(`^ ${NOTHING_CURRENT_WORDS} · \\d+ ${PARKED_WORDS} `).test(line.slice(heading.length))) return lane;
|
|
696
758
|
}
|
|
697
759
|
}
|
|
698
760
|
return null;
|
|
@@ -947,6 +1009,12 @@ export interface BriefingRequest {
|
|
|
947
1009
|
/** Those of `horizonLater` past their date (review of #511): the line
|
|
948
1010
|
* counts them as overdue. Absent: none said so. */
|
|
949
1011
|
readonly horizonOverdue?: readonly string[];
|
|
1012
|
+
/**
|
|
1013
|
+
* HOW MANY OPEN THREADS ARE PARKED, for this reader (P2, 2026-10-28;
|
|
1014
|
+
* `identity.ts#openCarry`): "Still open"'s count line says it after its
|
|
1015
|
+
* paren (`parkedTail`). Absent or 0: nothing said.
|
|
1016
|
+
*/
|
|
1017
|
+
readonly threadsParked?: number;
|
|
950
1018
|
}
|
|
951
1019
|
|
|
952
1020
|
export interface TrimEvent {
|
|
@@ -1555,7 +1623,9 @@ export function render(
|
|
|
1555
1623
|
// (`Self#composeLanes`), give it nothing. Not a lane: no trim row.
|
|
1556
1624
|
const elsewhereForms = elsewhereFormsOf(req.elsewhere, req.elsewhereShorter);
|
|
1557
1625
|
let elsewhere: string | undefined = elsewhereForms[0];
|
|
1558
|
-
|
|
1626
|
+
// `let`: once the parked count gives way (`hush` below), the rescues
|
|
1627
|
+
// compose without it too.
|
|
1628
|
+
let ctx: RescueCtx = { req, resolve, coreName, identity, head: arrivingHead(lanes.horizon), elsewhereForms };
|
|
1559
1629
|
// "Still open"'s last item left is its first, which outranks the line
|
|
1560
1630
|
// with its count (`openFirst`, as `keepFirstOpen` restores them): the line
|
|
1561
1631
|
// finds room for itself beside both, or steps down, before the trim loop
|
|
@@ -1585,9 +1655,26 @@ export function render(
|
|
|
1585
1655
|
// COUNTERPARTS, 2026-10-12, lightly held).
|
|
1586
1656
|
let fold = false;
|
|
1587
1657
|
let bare = false;
|
|
1658
|
+
// THE PARKED COUNT GIVES WAY FIRST (review of #675, 2026-10-28): "Still
|
|
1659
|
+
// open"'s parked words — its parked line, or ` · N parked` on its count
|
|
1660
|
+
// line or in the folded line — are an aside about what nobody touched in 14
|
|
1661
|
+
// lived days. They take room as the lanes' lines do, but before the loop
|
|
1662
|
+
// pops a "Who I am" item for them, and before a floor goes bare (every lane
|
|
1663
|
+
// untold) for them, they go quiet (`withoutParked`), and the loop composes
|
|
1664
|
+
// without them. `tellLost` still says them when the room turns out to hold
|
|
1665
|
+
// them. Without this, a folded line 12 bytes longer than the room went
|
|
1666
|
+
// bare: "Still open" untold, and the parked unsaid as well.
|
|
1667
|
+
let hushed = false;
|
|
1668
|
+
const lineReq = (): BriefingRequest => (hushed ? withoutParked(req) : req);
|
|
1669
|
+
const parkedIn = (lost: Partial<Record<LaneName, readonly string[]>>): boolean =>
|
|
1670
|
+
!hushed && (req.threadsParked ?? 0) >= 1 && ((lost.threads?.length ?? 0) > 0 || owedParked(lost, kept, req) !== null);
|
|
1671
|
+
const hush = (): void => {
|
|
1672
|
+
hushed = true;
|
|
1673
|
+
ctx = { ...ctx, req: withoutParked(req) };
|
|
1674
|
+
};
|
|
1588
1675
|
const lostNow = (): Partial<Record<LaneName, string[]>> => withoutNearby(lostByLane(lanes.overflow, trimmed, held, suppressList));
|
|
1589
1676
|
const linesFor = (lost: Partial<Record<LaneName, readonly string[]>>, k: Kept, folded: boolean): { more: Partial<Record<LaneName, string>>; fold?: string } =>
|
|
1590
|
-
folded ? foldParts(lost, k,
|
|
1677
|
+
folded ? foldParts(lost, k, lineReq()) : { more: pinnedLines(lost, k, lineReq()) };
|
|
1591
1678
|
|
|
1592
1679
|
for (;;) {
|
|
1593
1680
|
const lost = lostNow();
|
|
@@ -1633,6 +1720,12 @@ export function render(
|
|
|
1633
1720
|
break;
|
|
1634
1721
|
}
|
|
1635
1722
|
}
|
|
1723
|
+
// Not a "Who I am" item for the parked count (review of #675).
|
|
1724
|
+
if (lane === "identity" && parkedIn(lost)) {
|
|
1725
|
+
hush();
|
|
1726
|
+
stepped = true;
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1636
1729
|
const dropped = items.pop();
|
|
1637
1730
|
if (dropped === undefined) continue;
|
|
1638
1731
|
cut = { lane, id: dropped.id, strength: dropped.strength };
|
|
@@ -1644,7 +1737,11 @@ export function render(
|
|
|
1644
1737
|
// `arrivingFirst`: "Work here", the Yesterday line's titles, the
|
|
1645
1738
|
// handoffs' room, "Today, elsewhere", Arriving past its head) — and
|
|
1646
1739
|
// only when even that finds none do the lanes go untold (`bare`).
|
|
1647
|
-
|
|
1740
|
+
// "Still open"'s parked line is a lane's line like these (P2b): it
|
|
1741
|
+
// takes room the same way; when none is found the parked words go
|
|
1742
|
+
// quiet first (`hush`), and the lanes try again without them before
|
|
1743
|
+
// a bare floor goes without all of them.
|
|
1744
|
+
const counting = Object.keys(lost).length > 0 || owedParked(lost, kept, lineReq()) !== null;
|
|
1648
1745
|
if (counting && !fold) {
|
|
1649
1746
|
fold = true;
|
|
1650
1747
|
continue;
|
|
@@ -1653,7 +1750,8 @@ export function render(
|
|
|
1653
1750
|
const from: Rescued = { kept, trimmed: [...trimmed], yesterday, elsewhere, pinned: lost, composed: c, lent: base - req.budgetBytes, fold: true };
|
|
1654
1751
|
const got = takeRoom("arrivingFirst", from, kept, lost, trimmed, ctx, true);
|
|
1655
1752
|
if (got === null) {
|
|
1656
|
-
|
|
1753
|
+
if (parkedIn(lost)) hush();
|
|
1754
|
+
else bare = true;
|
|
1657
1755
|
} else {
|
|
1658
1756
|
for (const l of LANE_ORDER) kept[l] = got.kept[l];
|
|
1659
1757
|
trimmed.splice(0, trimmed.length, ...got.trimmed);
|
|
@@ -1767,6 +1865,7 @@ export function render(
|
|
|
1767
1865
|
const next = tell();
|
|
1768
1866
|
const same =
|
|
1769
1867
|
next.folded === told.folded &&
|
|
1868
|
+
next.parked === told.parked &&
|
|
1770
1869
|
JSON.stringify([next.more, next.untold, next.quiet]) === JSON.stringify([told.more, told.untold, told.quiet]);
|
|
1771
1870
|
if (same && next.composed.bytes <= budgetBytes) told = next;
|
|
1772
1871
|
else kept[lane][0] = top;
|
|
@@ -281,7 +281,7 @@ export function openSettlesCounts(store: Store): { open: number; withSettlesWhen
|
|
|
281
281
|
* WHICH OPEN THREADS ARE STILL CARRIED (2026-10-22, the open-threads brief;
|
|
282
282
|
* the one place the rule lives — the wake's "Still open", built and
|
|
283
283
|
* assembled, the reflection's `staleOpen` and its `noLongerCarried` count
|
|
284
|
-
* all read it). Of the open threads (`openThread`), one with no `eventDate
|
|
284
|
+
* all read it). Of the open threads (`openThread`), one with no `eventDate` still to come,
|
|
285
285
|
* not `asked`, untouched for `days` lived days or more
|
|
286
286
|
* (`SelfTunables.OPEN_CARRY_DAYS`) is NOT carried: the wake shows it in no
|
|
287
287
|
* lane ("Nearby" would read as carried still). It is not closed: the flag
|
|
@@ -291,6 +291,21 @@ export function openSettlesCounts(store: Store): { open: number; withSettlesWhen
|
|
|
291
291
|
* bundle or glimpsed as a footnote writes none of what counts, so being shown
|
|
292
292
|
* cannot keep it carried.
|
|
293
293
|
*
|
|
294
|
+
* PARKED (P2, 2026-10-28; roadmap 10-28, Mike's "ok your lean sounds good",
|
|
295
|
+
* lightly held): what this rule leaves out is what the owner-facing words
|
|
296
|
+
* now call PARKED — after 14 lived days untouched (`OPEN_CARRY_DAYS`, 21
|
|
297
|
+
* until P2), the same lived days "Still open" and `recall "still open"` count
|
|
298
|
+
* age in. An item that names what would settle it (`meta.settlesWhen`, S1) is
|
|
299
|
+
* never parked either: it has its own door, the reflection's `settlesOpen`,
|
|
300
|
+
* which a parked item would leave. The wake's "Still open" tail counts the
|
|
301
|
+
* parked (`briefing.ts#PARKED_WORDS`), the handle lists them after the
|
|
302
|
+
* carried ones, marked, and doctor's Open items line counts them. The rule
|
|
303
|
+
* is read live, at every wake, from the store's own facts — no flag is
|
|
304
|
+
* written — so a touch un-parks at once and a host whose nights never run
|
|
305
|
+
* parks all the same; the night records what it parked on the reflection's
|
|
306
|
+
* row (`detail.notCarried`) and its share says the count. `notCarried` keeps
|
|
307
|
+
* its name: reflection rows written since 10-22 carry it.
|
|
308
|
+
*
|
|
294
309
|
* `touched`: every open thread → the lived day it was last touched;
|
|
295
310
|
* `carried` the ones still carried, in the store's order (oldest born first).
|
|
296
311
|
* Fail-open for the wake: a store that cannot answer leaves all empty, and
|
|
@@ -299,24 +314,37 @@ export function openSettlesCounts(store: Store): { open: number; withSettlesWhen
|
|
|
299
314
|
export interface OpenCarry {
|
|
300
315
|
readonly touched: ReadonlyMap<string, number>;
|
|
301
316
|
readonly carried: readonly string[];
|
|
302
|
-
/** Open threads no longer carried → lived days untouched. */
|
|
317
|
+
/** Open threads no longer carried — parked — → lived days untouched. */
|
|
303
318
|
readonly notCarried: ReadonlyMap<string, number>;
|
|
304
319
|
}
|
|
305
320
|
|
|
306
|
-
/** The rule itself, on one thread's facts (see `openCarry`)
|
|
307
|
-
|
|
308
|
-
|
|
321
|
+
/** The rule itself, on one thread's facts (see `openCarry`): dated, asked or
|
|
322
|
+
* naming what would settle it (`settles`, P2), never parked. */
|
|
323
|
+
export function carriesOpen(
|
|
324
|
+
f: { readonly touchedDay: number; readonly dated: boolean; readonly asked: boolean; readonly settles?: boolean },
|
|
325
|
+
day: number,
|
|
326
|
+
days: number,
|
|
327
|
+
): boolean {
|
|
328
|
+
if (f.dated || f.asked || f.settles === true || !Number.isFinite(days)) return true;
|
|
309
329
|
return day - f.touchedDay < days;
|
|
310
330
|
}
|
|
311
331
|
|
|
312
332
|
/** `glimpses`: `SelfTunables.OPEN_CARRY_GLIMPSE_TOUCH` — true counts an
|
|
313
|
-
* unrated footnote as a touch again (the revert of the 10-22 call).
|
|
314
|
-
|
|
333
|
+
* unrated footnote as a touch again (the revert of the 10-22 call).
|
|
334
|
+
*
|
|
335
|
+
* DATED MEANS STILL TO COME (review of #674, 2026-10-28; the brief: "dated
|
|
336
|
+
* items (eventDate in the future) … probably never parked"): a date is
|
|
337
|
+
* never parked while it is ahead, inside its grace after (the week "Coming
|
|
338
|
+
* up" still says it was due) or repeating. A one-off whose date and grace
|
|
339
|
+
* are behind `at` (the store's own day, `Store#today`, by default) is parked
|
|
340
|
+
* like any open item once untouched for `days` lived days — before this it
|
|
341
|
+
* sat in "Still open" for good, which "Coming up" had already let go. */
|
|
342
|
+
export function openCarry(store: Store, day: number, days: number, glimpses = false, at?: string): OpenCarry {
|
|
315
343
|
const touched = new Map<string, number>();
|
|
316
344
|
const carried: string[] = [];
|
|
317
345
|
const notCarried = new Map<string, number>();
|
|
318
346
|
try {
|
|
319
|
-
for (const f of store.openThreadTouches({ glimpses })) {
|
|
347
|
+
for (const f of store.openThreadTouches({ glimpses, at: at ?? store.today() })) {
|
|
320
348
|
if (!openThread(store, f.id)) continue;
|
|
321
349
|
touched.set(f.id, f.touchedDay);
|
|
322
350
|
if (carriesOpen(f, day, days)) carried.push(f.id);
|
|
@@ -523,6 +551,10 @@ export interface Lanes {
|
|
|
523
551
|
later?: readonly string[];
|
|
524
552
|
/** Those of `later` past their date (review of #511): counted as overdue. */
|
|
525
553
|
overdue?: readonly string[];
|
|
554
|
+
/** How many open threads are parked for this composition's reader (P2,
|
|
555
|
+
* 2026-10-28, `openCarry`): "Still open"'s count line says it. Set by
|
|
556
|
+
* `Self`, not by `rankLanes`. */
|
|
557
|
+
parked?: number;
|
|
526
558
|
}
|
|
527
559
|
|
|
528
560
|
/**
|
package/src/core/self/index.ts
CHANGED
|
@@ -351,6 +351,10 @@ export interface StillOpenItem {
|
|
|
351
351
|
readonly date?: string;
|
|
352
352
|
/** What would settle it, when one was named (`meta.settlesWhen`, S1 2026-10-27). */
|
|
353
353
|
readonly settlesWhen?: string;
|
|
354
|
+
/** Parked (P2, 2026-10-28): untouched `OPEN_CARRY_DAYS` lived days, so in
|
|
355
|
+
* no lane of the wake; not closed, and a touch un-parks it. Listed after
|
|
356
|
+
* every carried item. */
|
|
357
|
+
readonly parked?: true;
|
|
354
358
|
}
|
|
355
359
|
|
|
356
360
|
/** The most characters of a title the `still open` handle gives. */
|
|
@@ -1107,10 +1111,13 @@ export class Self {
|
|
|
1107
1111
|
...supplied.filter((r) => r.due !== true && r.near === true),
|
|
1108
1112
|
...supplied.filter((r) => r.due !== true && r.near !== true),
|
|
1109
1113
|
];
|
|
1114
|
+
// Which open threads are still carried (2026-10-22, `openCarry`), and
|
|
1115
|
+
// how many are parked — counted on "Still open"'s tail (P2, 2026-10-28).
|
|
1116
|
+
const carry = openCarry(this.store, req.day, this.tunables.OPEN_CARRY_DAYS, this.tunables.OPEN_CARRY_GLIMPSE_TOUCH);
|
|
1110
1117
|
const lanes: Lanes = {
|
|
1118
|
+
...(req.omit === undefined && carry.notCarried.size > 0 ? { parked: carry.notCarried.size } : {}),
|
|
1111
1119
|
...rankLanes(scanned, horizon, this.tunables, {
|
|
1112
|
-
|
|
1113
|
-
carry: openCarry(this.store, req.day, this.tunables.OPEN_CARRY_DAYS, this.tunables.OPEN_CARRY_GLIMPSE_TOUCH),
|
|
1120
|
+
carry,
|
|
1114
1121
|
settledOver: settledOver(this.store),
|
|
1115
1122
|
// "Still open"'s unsettled ones rank after the rest (2026-10-18): one
|
|
1116
1123
|
// read of the pairs, for the open candidates only.
|
|
@@ -1173,11 +1180,15 @@ export class Self {
|
|
|
1173
1180
|
* only: no stamp, no return, no seen set — being listed is not a touch
|
|
1174
1181
|
* (`openCarry`), so the handle cannot keep a thread carried.
|
|
1175
1182
|
*
|
|
1183
|
+
* THEN THE PARKED (P2, 2026-10-28): every open thread the carry leaves out,
|
|
1184
|
+
* listed after the carried ones and marked `parked` — not closed, findable
|
|
1185
|
+
* here as well as by what it is about. `parked` counts them.
|
|
1186
|
+
*
|
|
1176
1187
|
* `reader` (O2, 2026-10-26): the folder asking, as the wake assembled there
|
|
1177
1188
|
* reads it — its threads first, the personal ones after, another folder's
|
|
1178
|
-
* work neither listed nor counted
|
|
1189
|
+
* work neither listed nor counted as parked. Absent: every thread.
|
|
1179
1190
|
*/
|
|
1180
|
-
stillOpen(day: number, reader?: ThreadReader): { items: StillOpenItem[];
|
|
1191
|
+
stillOpen(day: number, reader?: ThreadReader): { items: StillOpenItem[]; parked: number } {
|
|
1181
1192
|
const { open, carry } = this.openScanned(day);
|
|
1182
1193
|
const settled = settledOver(this.store);
|
|
1183
1194
|
const place = reader === undefined ? undefined : this.threadPlaceFor(reader);
|
|
@@ -1189,35 +1200,51 @@ export class Self {
|
|
|
1189
1200
|
...(place === undefined ? {} : { threadPlace: place }),
|
|
1190
1201
|
});
|
|
1191
1202
|
const byId = new Map(open.map((s) => [s.id, s] as const));
|
|
1192
|
-
const
|
|
1193
|
-
for (const id of [...lanes.threads.map((r) => r.id), ...(lanes.overflow?.threads ?? [])]) {
|
|
1194
|
-
const s = byId.get(id);
|
|
1195
|
-
if (s === undefined) continue;
|
|
1203
|
+
const item = (s: Scanned, parked: boolean): StillOpenItem => {
|
|
1196
1204
|
const first = s.doc.body.split("\n").find((l) => l.trim().length > 0) ?? "";
|
|
1197
1205
|
const whole = flatten((s.doc.title ?? "").trim() || first);
|
|
1198
1206
|
const title = whole.length <= STILL_OPEN_TITLE_CHARS ? whole : `${whole.slice(0, STILL_OPEN_TITLE_CHARS - 1).trimEnd()}…`;
|
|
1199
|
-
const touched = carry.touched.get(id) ?? Math.max(s.doc.bornDay, s.physics.lastUsedDay);
|
|
1207
|
+
const touched = carry.touched.get(s.id) ?? Math.max(s.doc.bornDay, s.physics.lastUsedDay);
|
|
1200
1208
|
const settles = s.unresolved ? settlesWhenOf(s.doc.meta) : null;
|
|
1201
|
-
|
|
1202
|
-
id,
|
|
1209
|
+
return {
|
|
1210
|
+
id: s.id,
|
|
1203
1211
|
title,
|
|
1204
1212
|
livedDaysSinceTouched: Math.max(0, day - touched),
|
|
1205
1213
|
...(s.reconsidering === true ? { reconsidering: true } : {}),
|
|
1206
1214
|
...(s.doc.eventDate === undefined ? {} : { date: s.doc.eventDate }),
|
|
1207
1215
|
...(settles === null ? {} : { settlesWhen: settles }),
|
|
1208
|
-
|
|
1216
|
+
...(parked ? { parked: true } : {}),
|
|
1217
|
+
};
|
|
1218
|
+
};
|
|
1219
|
+
const out: StillOpenItem[] = [];
|
|
1220
|
+
for (const id of [...lanes.threads.map((r) => r.id), ...(lanes.overflow?.threads ?? [])]) {
|
|
1221
|
+
const s = byId.get(id);
|
|
1222
|
+
if (s !== undefined) out.push(item(s, false));
|
|
1209
1223
|
}
|
|
1210
|
-
//
|
|
1211
|
-
// folder's work is not this
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1224
|
+
// THE PARKED, AFTER THE CARRIED (P2, 2026-10-28): listed and marked, the
|
|
1225
|
+
// most recently touched first; another folder's work is not this
|
|
1226
|
+
// reader's (O2), as the wake's count reads them (`parkedOf`).
|
|
1227
|
+
const parked = this.parkedOf(carry, day, place);
|
|
1228
|
+
for (const s of parked) out.push(item(s, true));
|
|
1229
|
+
return { items: out, parked: parked.length };
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* THE PARKED OPEN THREADS FOR ONE READER (P2, 2026-10-28): what the carry
|
|
1234
|
+
* leaves out (`openCarry`'s `notCarried`), less another folder's work when
|
|
1235
|
+
* a reader's place is given (O2), the most recently touched first, then by
|
|
1236
|
+
* id. One row read each; reads only.
|
|
1237
|
+
*/
|
|
1238
|
+
private parkedOf(carry: OpenCarry, day: number, place?: (s: Scanned) => "here" | "personal" | "out"): Scanned[] {
|
|
1239
|
+
const ids = [...carry.notCarried.entries()].sort((a, b) => a[1] - b[1] || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0)).map(([id]) => id);
|
|
1240
|
+
const out: Scanned[] = [];
|
|
1241
|
+
for (const id of ids) {
|
|
1242
|
+
const s = scanOne(this.store, id, day);
|
|
1243
|
+
if (s === null || !s.unresolved) continue;
|
|
1244
|
+
if (place !== undefined && place(s) === "out") continue;
|
|
1245
|
+
out.push(s);
|
|
1219
1246
|
}
|
|
1220
|
-
return
|
|
1247
|
+
return out;
|
|
1221
1248
|
}
|
|
1222
1249
|
|
|
1223
1250
|
/**
|
|
@@ -1300,6 +1327,9 @@ export class Self {
|
|
|
1300
1327
|
// reconsidered, which wait on a decision (2026-10-11).
|
|
1301
1328
|
const { open: openRead, carry, flagged } = this.openScanned(day);
|
|
1302
1329
|
const open = openRead.map(note);
|
|
1330
|
+
const place = req.reader === undefined ? undefined : this.threadPlaceFor(req.reader);
|
|
1331
|
+
// How many are parked for this reader (P2, 2026-10-28): its tail says so.
|
|
1332
|
+
const parked = carry.notCarried.size === 0 ? 0 : this.parkedOf(carry, day, place).length;
|
|
1303
1333
|
const fresh = rankLanes(open, horizon, this.tunables, {
|
|
1304
1334
|
carry,
|
|
1305
1335
|
settledOver: settled,
|
|
@@ -1307,7 +1337,7 @@ export class Self {
|
|
|
1307
1337
|
waiting: waitingIds(this.store, day),
|
|
1308
1338
|
workAtDelivery: this.tunables.CRAFT_AT_DELIVERY,
|
|
1309
1339
|
craftSince: craftSince(this.store),
|
|
1310
|
-
...(
|
|
1340
|
+
...(place === undefined ? {} : { threadPlace: place }),
|
|
1311
1341
|
...(coming.more.length === 0 ? {} : { horizonMore: coming.more }),
|
|
1312
1342
|
...(coming.later.length === 0 ? {} : { later: coming.later }),
|
|
1313
1343
|
});
|
|
@@ -1352,6 +1382,7 @@ export class Self {
|
|
|
1352
1382
|
},
|
|
1353
1383
|
...(coming.later.length === 0 ? {} : { later: coming.later }),
|
|
1354
1384
|
...(coming.overdue.length === 0 ? {} : { overdue: coming.overdue }),
|
|
1385
|
+
...(parked === 0 ? {} : { parked }),
|
|
1355
1386
|
};
|
|
1356
1387
|
return this.composeLanes(lanes, docs, sources, {
|
|
1357
1388
|
day,
|
|
@@ -1516,6 +1547,8 @@ export class Self {
|
|
|
1516
1547
|
...(lanes.later === undefined || lanes.later.length === 0 || req.omit !== undefined ? {} : { horizonLater: lanes.later }),
|
|
1517
1548
|
// And which of them are past their date, so it says "overdue" (review of #511).
|
|
1518
1549
|
...(lanes.overdue === undefined || lanes.overdue.length === 0 || req.omit !== undefined ? {} : { horizonOverdue: lanes.overdue }),
|
|
1550
|
+
// How many open threads are parked: "Still open"'s count line says so (P2, 2026-10-28).
|
|
1551
|
+
...(lanes.parked === undefined || lanes.parked === 0 || req.omit !== undefined ? {} : { threadsParked: lanes.parked }),
|
|
1519
1552
|
...(req.elsewhereShorter === undefined || req.elsewhere === undefined || req.omit !== undefined
|
|
1520
1553
|
? {}
|
|
1521
1554
|
: { elsewhereShorter: req.elsewhereShorter }),
|
|
@@ -131,7 +131,9 @@ export interface SelfTunables {
|
|
|
131
131
|
* beside `OPEN_CARRY_DAYS`, `briefing.ts#OPEN_TAIL_WORDS`.) "Untouched" is read as #489 D's `staleOpen`
|
|
132
132
|
* reads it (born or used), but the thresholds differ: the nightly
|
|
133
133
|
* close-offer looks from `REFLECT_TUNABLES.STALE_OPEN_DAYS` (4) and offers
|
|
134
|
-
* at most 5 a night, so it does not count what this counts.
|
|
134
|
+
* at most 5 a night, so it does not count what this counts. Since P2
|
|
135
|
+
* (2026-10-28) parks at the same 14, it orders only what is never parked:
|
|
136
|
+
* a thread that names what would settle it, or is `asked`. CAL.
|
|
135
137
|
*/
|
|
136
138
|
STILL_OPEN_STALE_DAYS: number;
|
|
137
139
|
/**
|
|
@@ -146,6 +148,14 @@ export interface SelfTunables {
|
|
|
146
148
|
* the memory stays in the store (in no lane of the wake), recall shows it, and any touch carries it
|
|
147
149
|
* again (`identity.ts#openCarry`, the one place the rule lives). Revert:
|
|
148
150
|
* very large (`Infinity` carries everything, as before). CAL.
|
|
151
|
+
*
|
|
152
|
+
* PARKED AT 14 (P2, 2026-10-28; roadmap 10-28, Mike agreed the lean,
|
|
153
|
+
* lightly held): 21 until then. What this leaves out is now called PARKED
|
|
154
|
+
* where the owner or a model reads it — the wake's tail counts it (`· N
|
|
155
|
+
* parked`), `recall "still open"` lists it after the carried ones, marked,
|
|
156
|
+
* doctor's Open items line counts it — and an item with a `settlesWhen` is
|
|
157
|
+
* never parked (its door is the reflection's `settlesOpen`). Lived days, as
|
|
158
|
+
* "Still open" counts age. Revert: 21 (or `Infinity`, every item carried).
|
|
149
159
|
*/
|
|
150
160
|
OPEN_CARRY_DAYS: number;
|
|
151
161
|
/**
|
|
@@ -487,7 +497,7 @@ export const SELF_TUNABLES: SelfTunables = {
|
|
|
487
497
|
THREADS_MAX: 5,
|
|
488
498
|
RECONSIDERING_MAX: 1,
|
|
489
499
|
STILL_OPEN_STALE_DAYS: 14,
|
|
490
|
-
OPEN_CARRY_DAYS:
|
|
500
|
+
OPEN_CARRY_DAYS: 14,
|
|
491
501
|
OPEN_CARRY_GLIMPSE_TOUCH: false,
|
|
492
502
|
HINTS_MAX: 8,
|
|
493
503
|
HORIZON_MAX: 6,
|
package/src/core/self/work.ts
CHANGED
|
@@ -502,6 +502,26 @@ export function workHereBytes(lines: readonly string[]): number {
|
|
|
502
502
|
return new TextEncoder().encode(`${workHereBlock(lines)}\n\n`).length;
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
+
/**
|
|
506
|
+
* THE PROJECT LINE'S OWN ROW (the 10-29 read: until now it left only ring
|
|
507
|
+
* events, so whether it showed could not be read): one durable row per wake
|
|
508
|
+
* delivered in a folder that belongs to a project, with the line on. `shown`,
|
|
509
|
+
* and when not, why (`reason`: `below-floor` — no belief above
|
|
510
|
+
* `WAKE_PROJECT_LINE_FLOOR`; `no-room` — not one line fitted its own byte
|
|
511
|
+
* budget and the reported ceiling; `no-sentinel` — the wake had nowhere to
|
|
512
|
+
* splice it); `lines` of `of` (the beliefs above the floor, capped at
|
|
513
|
+
* `WAKE_PROJECT_LINE_MAX`) and `held` (the project's live beliefs); `bytes`
|
|
514
|
+
* the line added (0 unshown), `budget` and `was` (the wake's bytes before);
|
|
515
|
+
* `ids` the beliefs it showed. The project as `ref`, the folder as `scope`,
|
|
516
|
+
* the session when the host named one. Ids, counts and bytes; never text.
|
|
517
|
+
* No `dedupKey`: each delivery is one showing (or not), as a turn's
|
|
518
|
+
* `recall.decision` is.
|
|
519
|
+
*/
|
|
520
|
+
export const PROJECT_LINE_EVENT = "self.project.line";
|
|
521
|
+
|
|
522
|
+
/** Why a project line showed or did not (`PROJECT_LINE_EVENT`'s `reason`). */
|
|
523
|
+
export type ProjectLineReason = "shown" | "below-floor" | "no-room" | "no-sentinel";
|
|
524
|
+
|
|
505
525
|
/**
|
|
506
526
|
* THE WAKE'S PROJECT LINE'S HEADING (wave 2 lane E, 2026-10-22; an
|
|
507
527
|
* experiment): what this folder's project is held to be, named, so its lines
|
package/src/core/store/index.ts
CHANGED
|
@@ -5336,9 +5336,10 @@ export class Store {
|
|
|
5336
5336
|
|
|
5337
5337
|
/** The open memories with the lived day each was last TOUCHED (born, used beyond a glimpse,
|
|
5338
5338
|
* revised — never a dream's or a reflection's return) and whether it is
|
|
5339
|
-
* dated
|
|
5340
|
-
*
|
|
5341
|
-
|
|
5339
|
+
* dated, `asked`, or names what would settle it (2026-10-22; `settles`
|
|
5340
|
+
* P2 2026-10-28; `reads-memories.ts#openThreadTouches`): what the parking
|
|
5341
|
+
* rule reads (`self/identity.ts#openCarry`). */
|
|
5342
|
+
openThreadTouches(opts: { glimpses?: boolean; at?: string } = {}): { id: string; touchedDay: number; dated: boolean; asked: boolean; settles: boolean }[] {
|
|
5342
5343
|
return memoryReads.openThreadTouches(this, opts);
|
|
5343
5344
|
}
|
|
5344
5345
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** `Store`'s reads of memories — a row, its copies and versions, the candidates and lists its readers ask for, the nearest neighbours, the claims era (bodies moved out of `store/index.ts`, 2026-10-11; the class keeps a delegate, and its doc comment, for each). */
|
|
2
|
-
import { calendarOverlaps, compareCalendarDates } from "../time.js";
|
|
2
|
+
import { addDays, calendarOverlaps, compareCalendarDates, isDay, parseCalendarDate } from "../time.js";
|
|
3
3
|
import { LATER_FEELING_SOURCES } from "./feelings.js";
|
|
4
4
|
import { TUNABLES as PHYSICS_TUNABLES } from "../physics/index.js";
|
|
5
5
|
import { StoreError } from "./errors.js";
|
|
6
|
+
import { SETTLES_WHEN_META_KEY } from "../types.js";
|
|
6
7
|
import {
|
|
7
8
|
CLAIMS_ERA_CUTOFF_KEY,
|
|
8
9
|
rowToPhysics,
|
|
@@ -423,18 +424,47 @@ function openTouchedSql(glimpses: boolean): string {
|
|
|
423
424
|
* THE OPEN THREADS AND WHEN EACH WAS LAST TOUCHED (2026-10-22): every live
|
|
424
425
|
* memory the loose `unresolved` match finds (`openThreadIds`'s match,
|
|
425
426
|
* answered by `memories_open`), with the lived day it was last touched
|
|
426
|
-
* (`openTouchedSql`) and the
|
|
427
|
-
* (`self/identity.ts#openCarry`, which also decides which are threads at all)
|
|
427
|
+
* (`openTouchedSql`) and the facts the parking rule reads
|
|
428
|
+
* (`self/identity.ts#openCarry`, which also decides which are threads at all):
|
|
429
|
+
* dated, `asked`, and — since P2 (2026-10-28) — whether it names what would
|
|
430
|
+
* settle it (`meta.settlesWhen` as non-blank text, as `types.ts#settlesWhenOf`
|
|
431
|
+
* reads it). Meta is JSON on the row: no schema change.
|
|
432
|
+
*
|
|
433
|
+
* `at` (review of #674, 2026-10-28): the calendar day asked about. With it,
|
|
434
|
+
* `dated` means a date still to come — ahead of `at`, or inside its grace
|
|
435
|
+
* after (`HOLD_GRACE_DAYS`, the days "Coming up" still says it was due) — or
|
|
436
|
+
* one that repeats. A one-off whose date and grace are behind it is no
|
|
437
|
+
* longer dated here: "Coming up" has let it go, and without this it sat in
|
|
438
|
+
* "Still open" for good, never parked. An unreadable date stays dated.
|
|
439
|
+
* Without `at`, any date is dated, as before.
|
|
428
440
|
*/
|
|
429
|
-
export function openThreadTouches(
|
|
441
|
+
export function openThreadTouches(
|
|
442
|
+
store: Store,
|
|
443
|
+
opts: { glimpses?: boolean; at?: string } = {},
|
|
444
|
+
): { id: string; touchedDay: number; dated: boolean; asked: boolean; settles: boolean }[] {
|
|
445
|
+
const settles = `CASE WHEN json_valid(m.meta) AND json_type(m.meta, '$.${SETTLES_WHEN_META_KEY}') = 'text'
|
|
446
|
+
AND TRIM(json_extract(m.meta, '$.${SETTLES_WHEN_META_KEY}')) <> '' THEN 1 ELSE 0 END`;
|
|
447
|
+
const at = opts.at !== undefined && isDay(opts.at) ? opts.at : null;
|
|
448
|
+
const behind = (date: string): boolean => {
|
|
449
|
+
if (at === null) return false;
|
|
450
|
+
const c = parseCalendarDate(date);
|
|
451
|
+
return c !== null && addDays(c.last, PHYSICS_TUNABLES.HOLD_GRACE_DAYS) < at;
|
|
452
|
+
};
|
|
430
453
|
return store["ops"]
|
|
431
|
-
.all<{ id: string; touched: number; event_date: string | null; status: string | null }>(
|
|
432
|
-
`SELECT m.id AS id, m.event_date AS event_date, m.status AS status, ${openTouchedSql(opts.glimpses === true)} AS touched
|
|
454
|
+
.all<{ id: string; touched: number; event_date: string | null; status: string | null; settles: number; recurring: number }>(
|
|
455
|
+
`SELECT m.id AS id, m.event_date AS event_date, m.status AS status, ${openTouchedSql(opts.glimpses === true)} AS touched,
|
|
456
|
+
${settles} AS settles, CASE WHEN m.meta LIKE '%"${RECURRING_META}":"%' THEN 1 ELSE 0 END AS recurring
|
|
433
457
|
FROM memories m
|
|
434
458
|
WHERE m.type = 'memory' AND m.archived = 0 AND m.meta LIKE '%"unresolved":true%'
|
|
435
459
|
ORDER BY m.birth_day, m.id`,
|
|
436
460
|
)
|
|
437
|
-
.map((r) => ({
|
|
461
|
+
.map((r) => ({
|
|
462
|
+
id: r.id,
|
|
463
|
+
touchedDay: r.touched,
|
|
464
|
+
dated: r.event_date !== null && (r.recurring === 1 || !behind(r.event_date)),
|
|
465
|
+
asked: r.status === "asked",
|
|
466
|
+
settles: r.settles === 1,
|
|
467
|
+
}));
|
|
438
468
|
}
|
|
439
469
|
|
|
440
470
|
/**
|