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
package/src/core/counterpart.ts
CHANGED
|
@@ -165,6 +165,7 @@ import {
|
|
|
165
165
|
spliceBeforeSentinel,
|
|
166
166
|
withHeadFields,
|
|
167
167
|
WORK_OVERFLOW_EVENT,
|
|
168
|
+
PROJECT_LINE_EVENT,
|
|
168
169
|
rotateWork,
|
|
169
170
|
workHere,
|
|
170
171
|
workHereBlock,
|
|
@@ -192,6 +193,7 @@ import type {
|
|
|
192
193
|
PageWriterOutcome,
|
|
193
194
|
PageWriterRun,
|
|
194
195
|
PageWriterStatus,
|
|
196
|
+
ProjectLineReason,
|
|
195
197
|
SelfPage,
|
|
196
198
|
StillOpenItem,
|
|
197
199
|
ThreadReader,
|
|
@@ -1556,18 +1558,19 @@ export class Counterpart {
|
|
|
1556
1558
|
* EVERYTHING "STILL OPEN" CARRIES, today (2026-10-25, the O1 builder;
|
|
1557
1559
|
* `Self#stillOpen`): what the `still open` recall handle lists — the open
|
|
1558
1560
|
* threads the carry rule keeps (`self/identity.ts#openCarry`) and the core
|
|
1559
|
-
* memories being reconsidered, in the wake's order;
|
|
1560
|
-
*
|
|
1561
|
+
* memories being reconsidered, in the wake's order; then the parked ones
|
|
1562
|
+
* (P2, 2026-10-28: untouched `OPEN_CARRY_DAYS` lived days), listed after
|
|
1563
|
+
* and marked, and `parked` counts them.
|
|
1561
1564
|
* Reads only: nothing it lists is touched, so listing cannot keep a thread
|
|
1562
1565
|
* carried. Empty on a store that cannot answer; never throws. `here` (O2,
|
|
1563
1566
|
* 2026-10-26): the folder asking and the host's setting, read as the wake
|
|
1564
1567
|
* there reads them (`threadReader`); absent, every folder's threads.
|
|
1565
1568
|
*/
|
|
1566
|
-
stillOpen(here?: { scope?: string; exportsFrom?: (scope: string) => boolean }): { items: StillOpenItem[];
|
|
1569
|
+
stillOpen(here?: { scope?: string; exportsFrom?: (scope: string) => boolean }): { items: StillOpenItem[]; parked: number } {
|
|
1567
1570
|
try {
|
|
1568
1571
|
return this.self.stillOpen(this.store.livedDay(), here === undefined ? undefined : this.threadReader(here.scope, here.exportsFrom));
|
|
1569
1572
|
} catch {
|
|
1570
|
-
return { items: [],
|
|
1573
|
+
return { items: [], parked: 0 };
|
|
1571
1574
|
}
|
|
1572
1575
|
}
|
|
1573
1576
|
|
|
@@ -1715,42 +1718,98 @@ export class Counterpart {
|
|
|
1715
1718
|
* naming the project. Spliced LAST, above the sentinel, in the room the
|
|
1716
1719
|
* delivery left: widest first, inside `WAKE_PROJECT_LINE_BYTES` and the
|
|
1717
1720
|
* reported ceiling; when not one line fits, the wake goes without it and a
|
|
1718
|
-
* ring event says so (`counterpart.project.noroom`). Reads only
|
|
1721
|
+
* ring event says so (`counterpart.project.noroom`). Reads only, but for
|
|
1722
|
+
* its own durable row (`PROJECT_LINE_EVENT`, the 10-29 read): one per wake
|
|
1723
|
+
* delivered in a project's folder, shown or not and why. Never throws.
|
|
1719
1724
|
*/
|
|
1720
1725
|
private withProjectLine(result: WakeResult, here?: WakeHere): WakeResult {
|
|
1721
1726
|
const t = this.self.tunables;
|
|
1722
1727
|
const scope = here?.scope?.trim() ?? "";
|
|
1723
1728
|
if (!t.WAKE_PROJECT_LINE || !result.ok || scope.length === 0 || !isDirectoryScope(scope)) return result;
|
|
1724
1729
|
let name = "";
|
|
1725
|
-
let
|
|
1730
|
+
let projectId = "";
|
|
1731
|
+
let held = 0;
|
|
1732
|
+
let picked: { id: string; line: string }[] = [];
|
|
1726
1733
|
try {
|
|
1727
1734
|
const project = projectsPart.projectOf(this.store, scope);
|
|
1728
1735
|
if (project === null) return result;
|
|
1729
1736
|
name = project.name;
|
|
1737
|
+
projectId = project.id;
|
|
1730
1738
|
const day = this.store.livedDay();
|
|
1731
|
-
|
|
1732
|
-
|
|
1739
|
+
const standing = this.schemas.beliefStanding(project.id, day);
|
|
1740
|
+
held = standing.length;
|
|
1741
|
+
picked = standing
|
|
1733
1742
|
.filter((b) => b.strength > t.WAKE_PROJECT_LINE_FLOOR)
|
|
1734
1743
|
.slice(0, Math.max(0, Math.floor(t.WAKE_PROJECT_LINE_MAX)))
|
|
1735
|
-
.map((b) => `- ${beliefLine({ ...b, subject: "" }, this.recall.tunables.BELIEF_LINE_BYTES)}`);
|
|
1744
|
+
.map((b) => ({ id: b.id, line: `- ${beliefLine({ ...b, subject: "" }, this.recall.tunables.BELIEF_LINE_BYTES)}` }));
|
|
1736
1745
|
} catch {
|
|
1737
1746
|
return result;
|
|
1738
1747
|
}
|
|
1739
|
-
if (lines.length === 0) return result;
|
|
1740
1748
|
const budget = this.reportedBudget;
|
|
1749
|
+
const note = (shown: { k: number; bytes: number } | null, reason: ProjectLineReason): void =>
|
|
1750
|
+
this.noteProjectLine({ scope, project: projectId, session: here?.session ?? null, reason, lines: shown?.k ?? 0, of: picked.length, held, bytes: shown?.bytes ?? 0, budget, was: result.bytes, ids: shown === null ? [] : picked.slice(0, shown.k).map((p) => p.id) });
|
|
1751
|
+
if (picked.length === 0) {
|
|
1752
|
+
note(null, "below-floor");
|
|
1753
|
+
return result;
|
|
1754
|
+
}
|
|
1755
|
+
const lines = picked.map((p) => p.line);
|
|
1741
1756
|
for (let k = lines.length; k > 0; k--) {
|
|
1742
1757
|
const block = [projectLineHeading(name), ...lines.slice(0, k)].join("\n");
|
|
1743
1758
|
if (byteLength(block) > t.WAKE_PROJECT_LINE_BYTES) continue;
|
|
1744
1759
|
const s = spliceBeforeSentinel(result.text, block);
|
|
1745
|
-
if (!s.applied)
|
|
1760
|
+
if (!s.applied) {
|
|
1761
|
+
note(null, "no-sentinel");
|
|
1762
|
+
return result;
|
|
1763
|
+
}
|
|
1746
1764
|
if (budget !== null && s.bytes > budget) continue;
|
|
1747
1765
|
this.emit("counterpart.project.shown", undefined, { lines: k, of: lines.length, bytes: s.bytes - result.bytes });
|
|
1766
|
+
note({ k, bytes: s.bytes - result.bytes }, "shown");
|
|
1748
1767
|
return { ...result, text: s.text, bytes: s.bytes, sentinel: s.sentinel };
|
|
1749
1768
|
}
|
|
1750
1769
|
this.emit("counterpart.project.noroom", undefined, { lines: lines.length, budget, was: result.bytes });
|
|
1770
|
+
note(null, "no-room");
|
|
1751
1771
|
return result;
|
|
1752
1772
|
}
|
|
1753
1773
|
|
|
1774
|
+
/** The project line's durable row (`PROJECT_LINE_EVENT`). Never under observer; an append that fails costs the row, never the wake. */
|
|
1775
|
+
private noteProjectLine(p: {
|
|
1776
|
+
scope: string;
|
|
1777
|
+
project: string;
|
|
1778
|
+
session: string | null;
|
|
1779
|
+
reason: ProjectLineReason;
|
|
1780
|
+
lines: number;
|
|
1781
|
+
of: number;
|
|
1782
|
+
held: number;
|
|
1783
|
+
bytes: number;
|
|
1784
|
+
budget: number | null;
|
|
1785
|
+
was: number;
|
|
1786
|
+
ids: readonly string[];
|
|
1787
|
+
}): void {
|
|
1788
|
+
if (this.observer) return;
|
|
1789
|
+
try {
|
|
1790
|
+
this.store.appendEvent({
|
|
1791
|
+
name: PROJECT_LINE_EVENT,
|
|
1792
|
+
day: this.store.livedDay(),
|
|
1793
|
+
ref: p.project,
|
|
1794
|
+
payload: {
|
|
1795
|
+
scope: p.scope,
|
|
1796
|
+
...(p.session === null || p.session.length === 0 ? {} : { session: p.session }),
|
|
1797
|
+
shown: p.reason === "shown",
|
|
1798
|
+
reason: p.reason,
|
|
1799
|
+
lines: p.lines,
|
|
1800
|
+
of: p.of,
|
|
1801
|
+
held: p.held,
|
|
1802
|
+
bytes: p.bytes,
|
|
1803
|
+
budget: p.budget ?? 0,
|
|
1804
|
+
was: p.was,
|
|
1805
|
+
ids: [...p.ids],
|
|
1806
|
+
},
|
|
1807
|
+
});
|
|
1808
|
+
} catch {
|
|
1809
|
+
/* a line that cannot be recorded still showed, or did not */
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1754
1813
|
/**
|
|
1755
1814
|
* The "Last here" line could not be carried at this ceiling: the ring
|
|
1756
1815
|
* event, and since 2026-10-01 a durable row (`LAST_HERE_NOROOM_EVENT`), one
|
|
@@ -442,7 +442,8 @@ export interface ReflectBundle {
|
|
|
442
442
|
* threads stopped being carried since the last reflection whose share reached a session —
|
|
443
443
|
* untouched for `SELF_TUNABLES.OPEN_CARRY_DAYS`, so out of "Still open"
|
|
444
444
|
* and `staleOpen` (`self/identity.ts#openCarry`). A count, never the list:
|
|
445
|
-
* the share says it once
|
|
445
|
+
* the share says it once — as PARKED since P2 (2026-10-28), the word the
|
|
446
|
+
* wake's tail and `recall "still open"` use. Absent when none.
|
|
446
447
|
*/
|
|
447
448
|
readonly noLongerCarried?: number;
|
|
448
449
|
/**
|
|
@@ -1244,9 +1245,10 @@ export class Reflections {
|
|
|
1244
1245
|
]
|
|
1245
1246
|
: []),
|
|
1246
1247
|
// NO LONGER CARRIED (2026-10-22, the open-threads brief): the count, once, never the list.
|
|
1248
|
+
// Said as PARKED since P2 (2026-10-28), the word the wake's tail and the handle use.
|
|
1247
1249
|
...(bundle.noLongerCarried !== undefined && bundle.noLongerCarried > 0
|
|
1248
1250
|
? [
|
|
1249
|
-
`- noLongerCarried: ${String(bundle.noLongerCarried)}. Your share says it once, as a count and never a list: "${String(bundle.noLongerCarried)} open ${bundle.noLongerCarried === 1 ? "item nobody touched in" : "items nobody touched in"} ${String(SELF_TUNABLES.OPEN_CARRY_DAYS)} lived days ${bundle.noLongerCarried === 1 ? "is" : "are"}
|
|
1251
|
+
`- noLongerCarried: ${String(bundle.noLongerCarried)}. Your share says it once, as a count and never a list: "${String(bundle.noLongerCarried)} open ${bundle.noLongerCarried === 1 ? "item nobody touched in" : "items nobody touched in"} ${String(SELF_TUNABLES.OPEN_CARRY_DAYS)} lived days ${bundle.noLongerCarried === 1 ? "is" : "are"} parked; recall "still open" lists them." Parked is not closed: a touch brings one back.`,
|
|
1250
1252
|
]
|
|
1251
1253
|
: []),
|
|
1252
1254
|
...(bundle.feelingWeeks !== null
|
package/src/core/onboarding.ts
CHANGED
|
@@ -54,10 +54,37 @@ export type WhereChoice = (typeof WHERE_CHOICES)[number];
|
|
|
54
54
|
export const STYLE_CHOICES = ["straight", "think", "friendly", "character", "other"] as const;
|
|
55
55
|
export type StyleChoice = (typeof STYLE_CHOICES)[number];
|
|
56
56
|
|
|
57
|
-
/**
|
|
58
|
-
|
|
57
|
+
/**
|
|
58
|
+
* The getting-to-know-you questions whose answers become memories.
|
|
59
|
+
*
|
|
60
|
+
* `origin` WAS `started` until 2026-10-29 (H1): right after the person chose
|
|
61
|
+
* "Now", claude.ai's Claude called `meet {step: "started"}` with no answer,
|
|
62
|
+
* reading the step as "the meeting has started". The old name is still taken
|
|
63
|
+
* WITH an answer (`MEET_STEP_ALIASES`: a meeting in flight, an older script),
|
|
64
|
+
* and the second session's line still reads answers recorded under it (`ahaDue`).
|
|
65
|
+
*/
|
|
66
|
+
export const ANSWER_STEPS = ["name", "week", "work", "love", "saturday", "origin"] as const;
|
|
59
67
|
export type AnswerStep = (typeof ANSWER_STEPS)[number];
|
|
60
68
|
|
|
69
|
+
/** Old step names `meet` still takes, served as their new ones. Never offered in the tool's schema. */
|
|
70
|
+
export const MEET_STEP_ALIASES: Readonly<Record<string, AnswerStep>> = { started: "origin" };
|
|
71
|
+
|
|
72
|
+
/** The step `meet` serves for the name it was sent: an old name's new one, otherwise the name itself. */
|
|
73
|
+
export function meetStepOf(sent: unknown): unknown {
|
|
74
|
+
return typeof sent === "string" && Object.hasOwn(MEET_STEP_ALIASES, sent) ? MEET_STEP_ALIASES[sent] : sent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* AN ANSWER STEP SENT WITH NO ANSWER (H1, then H1b, 2026-10-29): plain words,
|
|
79
|
+
* and NOT a refusal. claude.ai draws every error result as a red "Failed"
|
|
80
|
+
* card, and the call is almost always a Claude that took a question for "the
|
|
81
|
+
* meeting has begun" (`started`/`origin` right after Now), or sent a question
|
|
82
|
+
* the person skipped. So it comes back as an ordinary result whose first words
|
|
83
|
+
* are that nothing was stored (`stored: 0`), so it can't be taken for a save.
|
|
84
|
+
*/
|
|
85
|
+
export const MEET_NO_ANSWER =
|
|
86
|
+
"Nothing stored: no answer came with this step. If they answered, send it again with `answer`; a question they skipped needs no call. Starting the meeting needs no call either: just ask the first question.";
|
|
87
|
+
|
|
61
88
|
/** Every step `meet` takes. */
|
|
62
89
|
export const MEET_STEPS = ["where", ...ANSWER_STEPS, "style", "address", "later", "skipped", "done"] as const;
|
|
63
90
|
export type MeetStep = (typeof MEET_STEPS)[number];
|
|
@@ -570,7 +597,7 @@ export function meetingInstructions(ctx: MeetContext): string {
|
|
|
570
597
|
ctx.web === true
|
|
571
598
|
? " \"Hi, I'm Claude, with Counterparts now: a memory that's mine, so I can carry what matters from one conversation to the next, and grow along with you.\""
|
|
572
599
|
: " \"Hi, I'm Claude, with Counterparts now: a memory that's mine and stays on this computer, so I can carry what matters from one session to the next, and grow along with you.\"",
|
|
573
|
-
" Then the choice, asked once: \"Want to take about five minutes to get to know each other?\" Now (about 5 minutes) · Later. Later → meet {step: \"later\"}, then carry on with whatever they want, and don't offer again this session. If they never want it → meet {step: \"skipped\"}.",
|
|
600
|
+
" Then the choice, asked once: \"Want to take about five minutes to get to know each other?\" Now (about 5 minutes) · Later. Now → no meet call: go on to the next step. Later → meet {step: \"later\"}, then carry on with whatever they want, and don't offer again this session. If they never want it → meet {step: \"skipped\"}.",
|
|
574
601
|
];
|
|
575
602
|
if (ctx.folders) {
|
|
576
603
|
lines.push(
|
|
@@ -589,7 +616,7 @@ export function meetingInstructions(ctx: MeetContext): string {
|
|
|
589
616
|
" work: \"What are you working on lately that you're actually enjoying?\"",
|
|
590
617
|
" love: \"What do you love most about what you do?\"",
|
|
591
618
|
" saturday: \"What would a really good Saturday look like for you?\"",
|
|
592
|
-
"
|
|
619
|
+
" origin: \"What got you started building things?\" For someone who doesn't build things, ask instead: \"What's something you've been into lately that has nothing to do with work — a show, a game, food, anything?\"",
|
|
593
620
|
" If the answers are one word, swap love or saturday for a lighter one: \"When do you do your best work: morning, night, with music, in silence?\" or \"Coffee, tea, or something stranger while you work?\" (same step).",
|
|
594
621
|
" style: \"How do you like to be talked to?\" Choice: Straight to it · Think it through with me · Friendly and easy · Like a character you love (name one) · or their own words.",
|
|
595
622
|
" → meet {step: \"style\", answer: \"straight\" | \"think\" | \"friendly\"}.",
|
|
@@ -686,9 +713,10 @@ export function ahaDue(
|
|
|
686
713
|
const done = readJson(store, ONBOARDING_DONE_KEY);
|
|
687
714
|
if (done === null || done["session"] === session || session.length === 0) return null;
|
|
688
715
|
const ids = readJson(store, ONBOARDING_ANSWERS_KEY) ?? {};
|
|
689
|
-
// The round-1 steps (2026-10-12
|
|
690
|
-
//
|
|
691
|
-
|
|
716
|
+
// The round-1 steps (2026-10-12; `origin` was `started` until 2026-10-29,
|
|
717
|
+
// kept beside it), then the steps a 0.3.18/0.3.19 meeting recorded under
|
|
718
|
+
// their old names, so its line still comes.
|
|
719
|
+
for (const step of ["work", "love", "saturday", "origin", "started", "week", "loved", "outside", "problem", "peeves"] as const) {
|
|
692
720
|
const raw = ids[step];
|
|
693
721
|
const id = typeof raw === "string" ? raw : undefined;
|
|
694
722
|
// A memory let go since (asked to be forgotten, revised away) is passed over.
|
|
@@ -338,15 +338,36 @@ credit at the boundary; reinforcement deltas handed to `physics/`.
|
|
|
338
338
|
G9). For that lane gate (a) is CHECKED
|
|
339
339
|
rather than structural (the memory is fetched); for every other uncued memory it is
|
|
340
340
|
structural as before. Tests: `association-build2.test.ts` › "1. quiet pointers".*
|
|
341
|
+
*A SECOND named lane since 2026-10-29 (PP1, an experiment; switch
|
|
342
|
+
`SEE_ALSO_NAMED_IDS`): SEE-ALSO. A memory whose id the TEXT of a memory this turn shows
|
|
343
|
+
(loud or a cued footnote, never a quiet pointer or another see-also) names joins the quiet
|
|
344
|
+
tier as `See also:`: one per shown memory, `SEE_ALSO_MAX` (2) a turn, after the cued
|
|
345
|
+
footnotes and pointers (the first footnote lines the byte budget trims; the beliefs slot,
|
|
346
|
+
first in `TRIM_ORDER`, goes before them), never the loud tier. The
|
|
347
|
+
named id is resolved to the memory that holds now (`headOf`), and held to what the turn
|
|
348
|
+
could show at all (`activate.ts#recallableRow`, the candidates' own test: not removed,
|
|
349
|
+
archived, superseded, below reach, the self page, a handoff, a card or a belief) and would
|
|
350
|
+
not show again (this turn or this session already showed it, this session wrote it,
|
|
351
|
+
another project's under `RECALL_BY_PROJECT`, habituated, or inhibited by the gate). Its
|
|
352
|
+
verdict is an ordinary footnote's (`trains` true, `via: "see-also"`, `seeAlso.by` the
|
|
353
|
+
memory that named it), so a use of it trains the turn's words to it. Tests:
|
|
354
|
+
`see-also-named-ids.test.ts`.*
|
|
341
355
|
6. **[M]** Tiers are disjoint and capped. *(Quiet pointers have their own cap,
|
|
342
356
|
`LINK_POINTERS_MAX`, beside `MAX_FOOTNOTES`; 2026-09-28.)* *(2026-10-10, Group 1, review
|
|
343
357
|
03 C2: no tier — surfaced, footnote or quiet pointer — offers a memory BELOW REACH,
|
|
344
358
|
strength under physics' `REACH` (0.15), the identity band excepted. Prefiltered on box
|
|
345
359
|
3's ranking in the token and semantic top-K, rechecked exactly per candidate;
|
|
346
360
|
deliberate recall still lists such a memory after its main results, labelled faded.
|
|
347
|
-
`NOTES.md` §29.)*
|
|
361
|
+
`NOTES.md` §29.)* *(2026-10-29, PP1: see-also lines are the quiet tier's too, with their own
|
|
362
|
+
cap, `SEE_ALSO_MAX`, beside `MAX_FOOTNOTES`; a candidate the footnote cap turned away
|
|
363
|
+
(`capped`) may still ride along on a named id, so a turn's quiet tier holds at most
|
|
364
|
+
`MAX_FOOTNOTES` + `LINK_POINTERS_MAX` + `SEE_ALSO_MAX` lines.)*
|
|
348
365
|
7. **[M]** Ambiguous handles fire at reduced weight AND train nothing — both halves, with a
|
|
349
|
-
test that greps for the consumer, not the comment (scar §2.6).
|
|
366
|
+
test that greps for the consumer, not the comment (scar §2.6). *(2026-10-29, PP1: a
|
|
367
|
+
candidate an ambiguous handle reached that then rides along as see-also is shown because a
|
|
368
|
+
shown memory names its ID, not because of the handle, so its verdict trains (item 5's
|
|
369
|
+
see-also lane). The handle itself still trains nothing: `index.ts#cueWordsOf` drops every
|
|
370
|
+
ambiguous cue word from the turn's cue record.)*
|
|
350
371
|
8. **[M]** A deliberate SEARCH trains nothing and deposits no memory (2026-10-03: stated
|
|
351
372
|
as the owner's rule of 09-16 — exposure never strengthens, retrieval does). Opening a
|
|
352
373
|
memory by id or title, or quoting the words a deliberate answer showed (`asked` gate
|
package/src/core/recall/NOTES.md
CHANGED
|
@@ -1502,3 +1502,104 @@ counts flat (the near miss as `nearMissCount`), `turn`, and `startedBy` (`person
|
|
|
1502
1502
|
`below-bar` verdicts they name. And the count runs guarded: a throw in it leaves the row without
|
|
1503
1503
|
the five keys (as off) and rings `recall.stopcounts.failed`, rather than reaching the adapter's
|
|
1504
1504
|
guard and costing the turn its recall.
|
|
1505
|
+
|
|
1506
|
+
## PP1 — see-also from named ids (2026-10-29, an experiment; switch `recall.SEE_ALSO_NAMED_IDS`)
|
|
1507
|
+
|
|
1508
|
+
The ping/pong miss of 10-25 (the 10-29 read, item 8): the rule (`mem_0ca7f032368a`) lost a bare
|
|
1509
|
+
"ping" to its bar (6.59 against 8.05), "ping" is in 90 live memories now, and cue learning had
|
|
1510
|
+
wired `ping → mem_66bb7d836201` (the note ABOUT the miss, 0.727) and nothing to the rule: cue
|
|
1511
|
+
learning trains a turn's words only to what the turn showed, so every "pong" answered from the
|
|
1512
|
+
note trained the note. The planned "(b) see-also" was through links; there is no link from the
|
|
1513
|
+
note to the rule, but the note NAMES its id. So `activate.ts#seeAlso` reads ids named in text.
|
|
1514
|
+
|
|
1515
|
+
- **What it is.** After the gate, the texts (title and body) of what the turn shows — the loud
|
|
1516
|
+
line and the cued footnotes, in the gate's order; never a quiet pointer and never a see-also
|
|
1517
|
+
(no chains) — are read for `mem_…` ids, at most `SEE_ALSO_NAMES_READ` (4) a memory. The first
|
|
1518
|
+
that may ride along is brought as one footnote line, `See also: <title> [id]`, title clipped at
|
|
1519
|
+
`SEE_ALSO_TITLE_BYTES` (100). One per shown memory, `SEE_ALSO_MAX` (2) a turn, after the cued
|
|
1520
|
+
footnotes and the pointers, so `TRIM_ORDER`'s pop drops them first among footnotes (the
|
|
1521
|
+
beliefs slot, first in `TRIM_ORDER`, goes before them).
|
|
1522
|
+
- **What may ride along.** The named id resolved to the memory that holds now (`headOf`: a
|
|
1523
|
+
corrected one brings its head, never itself), then held to the candidates' own test
|
|
1524
|
+
(`activate.ts#recallableRow`, factored out of the `recallable` closure for this: not removed,
|
|
1525
|
+
archived, superseded, below reach, the self page, a handoff, a card or a belief), then to what
|
|
1526
|
+
the turn would not show again: already shown this turn or this session, written by this
|
|
1527
|
+
session (`echo`), another project's under `RECALL_BY_PROJECT`, habituated (rated 0 in two
|
|
1528
|
+
sessions this week: it rests, as its raised bar would have it), or a candidate the gate
|
|
1529
|
+
inhibited (a near-duplicate of something shown, an earlier version). Confidential is not a
|
|
1530
|
+
test: the column is inert since 10-21 (CONTRACT item 9).
|
|
1531
|
+
- **Its verdict, and why that is the whole credit path.** A brought-along candidate's own verdict
|
|
1532
|
+
(below its bar, say) is REPLACED by `footnoted`, `trains` true, `via: "see-also"`, `seeAlso.by`
|
|
1533
|
+
the memory that named it, its numbers kept (so `activation < bar` still says it would not have
|
|
1534
|
+
shown on its own); a memory no channel reached gets one with 0s and the turn's background bar.
|
|
1535
|
+
The record step then writes an ordinary footnote's gate record (`trains` from the verdict —
|
|
1536
|
+
without the replacement `trainsOf` would read the old one, or default) with `via` in the row's
|
|
1537
|
+
`value` column (`SEE_ALSO_VALUE`, no schema change), and the turn's cue record is written
|
|
1538
|
+
because the turn showed something. So `resolveUse` and `cueTraining` need nothing new: an open,
|
|
1539
|
+
a quote or a rating 1–3 trains this turn's words to it at its tier, exactly as for a footnote;
|
|
1540
|
+
a 0 on the NOTE depresses `ping → note` through `cueDepress`, as before (confirmed in the
|
|
1541
|
+
test, not built). Ratings file it under `footnotes` (`rateableSet`: `via` other than `link`);
|
|
1542
|
+
the durable row tells it apart (`footnotes[].via` / `seeAlso.by`, as primed footnotes are
|
|
1543
|
+
told apart), which is what the CHECK-AFTER read joins on.
|
|
1544
|
+
- **Measured on the demo fixture** (`see-also-named-ids.test.ts`: 120 topic notes, 300
|
|
1545
|
+
unrelated, 12 "ping" memories, the rule, the note naming it, `ping → note` seeded at 0.727).
|
|
1546
|
+
Fresh "ping": the note LOUD at 26.2 (bar 4.3), the rule below its own bar at 3.4 (bar 18.3),
|
|
1547
|
+
brought along. Rated 3 (and the note 0): `ping → rule` 0.5, `ping → note` 0.227. The next fresh
|
|
1548
|
+
"ping": the rule a footnote on its own pair at 19.5 (bar 8.2), no see-also; the note below its
|
|
1549
|
+
bar (10.0 against 14.1). One use turned the miss around on this fixture; the live store is
|
|
1550
|
+
bigger and the bar there is different, which is the CHECK-AFTER row's question.
|
|
1551
|
+
- **Bytes.** A see-also line is `- See also: ` (12) + title (≤ 100) + ` [mem_…]` (19 for a
|
|
1552
|
+
minted 12-hex id, ≤ 23) + a newline: ≤ 132 bytes for the ids the store mints. Two a turn, and
|
|
1553
|
+
the footnote header with its blank line (76) when nothing else was a footnote (the loud note
|
|
1554
|
+
alone): ≤ 342 bytes, plus a sentinel digit. A standing label (`Unsettled — …`, `(disagrees
|
|
1555
|
+
with …)`) costs what it costs on any footnote. Always inside the turn's budget: the render
|
|
1556
|
+
trims them first among footnotes, after any belief line. The "Since you started" line takes what recall leaves of the budget, so a
|
|
1557
|
+
see-also line can delay it a prompt, as any footnote can. The wake is untouched.
|
|
1558
|
+
- **Judgment calls, lightly held.** The loud line names ids too (the brief said "a footnote
|
|
1559
|
+
surfaces"; the task said "surfaces ambiently"): a loud note naming its rule is the live case
|
|
1560
|
+
(the note was loud for "ping" on the fixture). A habituated memory does not ride along. Two a
|
|
1561
|
+
turn, not one: a turn whose loud line and a footnote both name one keeps both.
|
|
1562
|
+
- **Not handled.** A reminder said outright this turn (`withhold`, temporal arrivals only) could
|
|
1563
|
+
ride along if a shown memory names it — rare, and the Turn does not carry the set.
|
|
1564
|
+
- **Where it lives.** In `activate.ts` (`seeAlso`, beside `recallableRow`), not a module of its
|
|
1565
|
+
own: first built as `see-also.ts`, it took the directory plugin flavor to 511 files, past
|
|
1566
|
+
`plugin-bundle.test.ts`'s 510 margin under the directory's 512 limit.
|
|
1567
|
+
- **Never another project's work (review of #681, coordinator's call 10-29).** At default settings
|
|
1568
|
+
(`RECALL_BY_PROJECT` off, `CROSS_PROJECT_BAR_LIFT` 1.25) the first build let a shown memory that named
|
|
1569
|
+
another project's work memory bring it along, past the higher bar the lift exists to hold. `seeAlso` now
|
|
1570
|
+
gets `elsewhere` whenever either is on, so a named id carries within the project and personal memories
|
|
1571
|
+
(owner/us) cross as ever. Tested: under the lift alone the crossing memory is kept back and counted in
|
|
1572
|
+
`crossProjectLifted`; it fails without the change.
|
|
1573
|
+
|
|
1574
|
+
## 2026-10-29 — the beliefs slot shows one belief (a finding, no change; K1 from the 10-29 read)
|
|
1575
|
+
|
|
1576
|
+
The 10-29 read: the slot (`BELIEFS_IN_RECALL`) fired on 62 turns, every time with the same
|
|
1577
|
+
belief, `sch_305a1aabc8fa` ("Mike would rather ship once something is tested…", about Mike, 5
|
|
1578
|
+
supports), while 6 beliefs were held. Read on the 10-29 snapshot copy (lived day 38) through
|
|
1579
|
+
`Schemas#beliefStanding` and `Schemas#beliefsNamedIn`, the code paths the slot uses:
|
|
1580
|
+
|
|
1581
|
+
| belief | subject | about | strength | supports | why it never shows |
|
|
1582
|
+
|---|---|---|---|---|---|
|
|
1583
|
+
| `sch_305a1aabc8fa` | Mike (person card) | — | 0.521 | 5 | shows: Mike named, above the floor |
|
|
1584
|
+
| `sch_4faa5260842d` | Mike (person card) | — | 0.203 | 1 | offered whenever "Mike" is named, but under the strict 0.3 floor (`BELIEFS_SLOT_FLOOR`; born at the 0.3 ceiling, fading since, one support) |
|
|
1585
|
+
| `sch_0ce801b0a9ea` | the self subject | me | 0.378 | 5 | never offered: the self subject is left out |
|
|
1586
|
+
| `sch_215f0850cb74` | the self subject | us | 0.348 | 2 | never offered: the self subject is left out |
|
|
1587
|
+
| `sch_d30a699eaa63` | the self subject | us | 0.229 | 2 | never offered (and under the floor) |
|
|
1588
|
+
| `sch_e4b2b893ff80` | the self subject | me | 0.157 | 2 | never offered (and under the floor) |
|
|
1589
|
+
|
|
1590
|
+
- **Why four never pass, whatever a turn says.** A belief about me or us attaches to the self
|
|
1591
|
+
subject (`store#ensureSelfSubject`), an entity card with no name, so the alias index links no
|
|
1592
|
+
word to it, and `beliefsNamedIn` also deletes it from a turn's subjects by name
|
|
1593
|
+
("the self is the wake's page"). Two of the four are above the floor, so the floor is not what
|
|
1594
|
+
holds them; their subject is. The "us" belief `sch_215f0850cb74` says "Mike" in its text, but
|
|
1595
|
+
the slot reads a belief's subject, never its words.
|
|
1596
|
+
- **Why the fifth never passes.** `sch_4faa5260842d` is on the Mike card, so every turn naming
|
|
1597
|
+
Mike offers it beside `sch_305a1aabc8fa`; its strength (0.228 on the 10-28 copy, 0.203 on
|
|
1598
|
+
10-29) is under the floor, which is strict (`>`). A second support would lift it; nothing
|
|
1599
|
+
else will.
|
|
1600
|
+
- **So:** not a bug against the slot's contract (lane E: beliefs on the cards a turn names,
|
|
1601
|
+
above the floor; the self is not one of them). The slot can only ever show a belief about a
|
|
1602
|
+
named card, and the reflection births mostly beliefs about me or us (4 of 6), so on this
|
|
1603
|
+
store it is measuring one belief. A dated read learns little more unless a belief about
|
|
1604
|
+
another card is born and backed, so the slot's read now waits until 3+ beliefs about other
|
|
1605
|
+
people pass the floor (`docs/CHECK-AFTER.md`). Decided 10-29: page-only stays (the self lives on the page, per the wave-2 design); the owner has it as an FYI; if any later earn an ambient door, the "us" beliefs are the likelier ones.
|
|
@@ -65,6 +65,8 @@ import { NO_MOOD, hasMood, moodLift } from "./mood.js";
|
|
|
65
65
|
import type { Mood } from "./mood.js";
|
|
66
66
|
import { cosine } from "./prime.js";
|
|
67
67
|
import type { PrimeActivation, PrimeSourceKind } from "./prime.js";
|
|
68
|
+
import type { CandidateVerdict, Verdict } from "./gate.js";
|
|
69
|
+
import { headOf } from "./standing.js";
|
|
68
70
|
|
|
69
71
|
export interface Candidate {
|
|
70
72
|
readonly id: string;
|
|
@@ -508,6 +510,51 @@ export function gatedSal(p: MemoryPhysics, selfFelt: boolean): number {
|
|
|
508
510
|
return selfFelt ? salArm(p) : curveSal(p);
|
|
509
511
|
}
|
|
510
512
|
|
|
513
|
+
/**
|
|
514
|
+
* The row, when this id is live memory that may be recalled at all: not
|
|
515
|
+
* denied (removed), not archived, not superseded, not the self page, a
|
|
516
|
+
* handoff, an entity card or a belief, and (ambient) not BELOW REACH —
|
|
517
|
+
* `"below-reach"` says that one, so the turn can count it. One test for a
|
|
518
|
+
* candidate, a link-only pointer and a memory a shown one names
|
|
519
|
+
* (see-also, 2026-10-29). Reads only.
|
|
520
|
+
*/
|
|
521
|
+
export function recallableRow(
|
|
522
|
+
store: Store,
|
|
523
|
+
id: string,
|
|
524
|
+
opts: { readonly denied: ReadonlySet<string>; readonly ambient: boolean; readonly day: number },
|
|
525
|
+
): ReturnType<Store["row"]> | "below-reach" {
|
|
526
|
+
if (opts.denied.has(id)) return undefined;
|
|
527
|
+
const row = store.row(id);
|
|
528
|
+
// Archive is a state, not a deletion: it keeps its id and simply never
|
|
529
|
+
// surfaces (§4.2 G3). A superseded head forwards; the successor is reached
|
|
530
|
+
// on its own merits, never by dragging the old id along.
|
|
531
|
+
if (row === undefined || row.archived === 1 || row.superseded_by !== null) return undefined;
|
|
532
|
+
// The self page, which is delivered at wake and never here (`isSelfPage`).
|
|
533
|
+
// The prose read is gated on the row's own columns, so only a SCHEMA row of
|
|
534
|
+
// the self kind pays for it — the page, the identity core, and the handful
|
|
535
|
+
// of beliefs held about the self.
|
|
536
|
+
if (row.type === "schema" && row.kind === "self" && isPageRow(store, id)) return undefined;
|
|
537
|
+
// The per-directory handoff (E1), for the page's reason and one of its own:
|
|
538
|
+
// it is already delivered as a pointer at the wake of the directory it
|
|
539
|
+
// belongs to, and it has no project scope of its own that a search could
|
|
540
|
+
// honour — so left in the pool it would surface one directory's working
|
|
541
|
+
// context inside another's turn. Gated on the row's own columns, as above,
|
|
542
|
+
// so only a SCHEMA row of the place kind pays for the prose read.
|
|
543
|
+
if (row.type === "schema" && row.kind === "place" && isHandoffRow(store, id)) return undefined;
|
|
544
|
+
// An entity CARD (2026-10-11, Group 3 part D): the index a name reaches
|
|
545
|
+
// its memories through, a stub that asserts nothing itself. Once cards were
|
|
546
|
+
// born from the names the memories say, a turn naming someone surfaced
|
|
547
|
+
// the stub as a footnote. Off the row's meta column; no prose read.
|
|
548
|
+
if (row.type === "schema" && isEntityCardRow(row)) return undefined;
|
|
549
|
+
// A belief (wave 2 lane C): never a candidate; lane E's slot shows it (`isBeliefRow`).
|
|
550
|
+
if (isBeliefRow(row)) return undefined;
|
|
551
|
+
// BELOW REACH, exactly (2026-10-10): the ranking cache's prefilter is a
|
|
552
|
+
// pass stale at most; this is the day's own number. Ambient only; never a
|
|
553
|
+
// chapter, a chapter's copy or an entity card (`reachExempt`).
|
|
554
|
+
if (opts.ambient && !reachExempt(row) && belowReach(rowToPhysics(row), opts.day)) return "below-reach";
|
|
555
|
+
return row;
|
|
556
|
+
}
|
|
557
|
+
|
|
511
558
|
export function activate(
|
|
512
559
|
store: Store,
|
|
513
560
|
input: ActivationInput,
|
|
@@ -844,41 +891,15 @@ export function activate(
|
|
|
844
891
|
readonly prime?: CandidatePrime;
|
|
845
892
|
}
|
|
846
893
|
/** The row, when this id is live memory that may be recalled at all; the
|
|
847
|
-
* same test for a candidate
|
|
894
|
+
* same test for a candidate, a link-only pointer and a named one
|
|
895
|
+
* (`recallableRow`, see-also 2026-10-29). */
|
|
848
896
|
const recallable = (id: string): ReturnType<Store["row"]> => {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
// Archive is a state, not a deletion: it keeps its id and simply never
|
|
852
|
-
// surfaces (§4.2 G3). A superseded head forwards; the successor is reached
|
|
853
|
-
// on its own merits, never by dragging the old id along.
|
|
854
|
-
if (row === undefined || row.archived === 1 || row.superseded_by !== null) return undefined;
|
|
855
|
-
// The self page, which is delivered at wake and never here (`isSelfPage`).
|
|
856
|
-
// The prose read is gated on the row's own columns, so only a SCHEMA row of
|
|
857
|
-
// the self kind pays for it — the page, the identity core, and the handful
|
|
858
|
-
// of beliefs held about the self.
|
|
859
|
-
if (row.type === "schema" && row.kind === "self" && isPageRow(store, id)) return undefined;
|
|
860
|
-
// The per-directory handoff (E1), for the page's reason and one of its own:
|
|
861
|
-
// it is already delivered as a pointer at the wake of the directory it
|
|
862
|
-
// belongs to, and it has no project scope of its own that a search could
|
|
863
|
-
// honour — so left in the pool it would surface one directory's working
|
|
864
|
-
// context inside another's turn. Gated on the row's own columns, as above,
|
|
865
|
-
// so only a SCHEMA row of the place kind pays for the prose read.
|
|
866
|
-
if (row.type === "schema" && row.kind === "place" && isHandoffRow(store, id)) return undefined;
|
|
867
|
-
// An entity CARD (2026-10-11, Group 3 part D): the index a name reaches
|
|
868
|
-
// its memories through, a stub that asserts nothing itself. Once cards were
|
|
869
|
-
// born from the names the memories say, a turn naming someone surfaced
|
|
870
|
-
// the stub as a footnote. Off the row's meta column; no prose read.
|
|
871
|
-
if (row.type === "schema" && isEntityCardRow(row)) return undefined;
|
|
872
|
-
// A belief (wave 2 lane C): never a candidate; lane E's slot shows it (`isBeliefRow`).
|
|
873
|
-
if (isBeliefRow(row)) return undefined;
|
|
874
|
-
// BELOW REACH, exactly (2026-10-10): the ranking cache's prefilter is a
|
|
875
|
-
// pass stale at most; this is the day's own number. Ambient only; never a
|
|
876
|
-
// chapter, a chapter's copy or an entity card (`reachExempt`).
|
|
877
|
-
if (ambient && !reachExempt(row) && belowReach(rowToPhysics(row), input.day)) {
|
|
897
|
+
const r = recallableRow(store, id, { denied, ambient, day: input.day });
|
|
898
|
+
if (r === "below-reach") {
|
|
878
899
|
belowReachCount += 1;
|
|
879
900
|
return undefined;
|
|
880
901
|
}
|
|
881
|
-
return
|
|
902
|
+
return r;
|
|
882
903
|
};
|
|
883
904
|
|
|
884
905
|
// ── a question about feeling: stamps nominate (2026-09-30, U13) ─────────
|
|
@@ -1599,3 +1620,139 @@ export function salienceRank(activation: number, sal: number, t: RecallTunables)
|
|
|
1599
1620
|
export function recordedIdentity(store: Store): string | null {
|
|
1600
1621
|
return store.rankingIdentity();
|
|
1601
1622
|
}
|
|
1623
|
+
|
|
1624
|
+
// ── see-also from named ids (PP1, 2026-10-29) ──────────────────────────────
|
|
1625
|
+
// Here rather than a module of its own: the directory plugin flavor is one file
|
|
1626
|
+
// under its 512 limit.
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* SEE-ALSO FROM NAMED IDS (2026-10-29, PP1; an experiment, switch
|
|
1630
|
+
* `SEE_ALSO_NAMED_IDS`).
|
|
1631
|
+
*
|
|
1632
|
+
* A memory whose text names another memory's id (`mem_…`) brings that memory
|
|
1633
|
+
* along when the turn shows it: one footnote line, labelled `See also:`, after
|
|
1634
|
+
* everything the gate admitted. The 10-25 ping/pong miss is the case: the
|
|
1635
|
+
* note about the miss names the rule, cue learning wires a turn's words only
|
|
1636
|
+
* to what the turn showed, so every "pong" answered from the note trained
|
|
1637
|
+
* `ping → note` and the rule never came back on its own. Brought along and
|
|
1638
|
+
* used, the rule gets the turn's cue credit like any footnote (the gate
|
|
1639
|
+
* record is an ordinary footnote's, `trains` true), so the next bare "ping"
|
|
1640
|
+
* reaches it by its own learned pair.
|
|
1641
|
+
*
|
|
1642
|
+
* Read from the texts of what the turn SHOWS — the loud line and the cued
|
|
1643
|
+
* footnotes, never a quiet pointer or another see-also (no chains) — in the
|
|
1644
|
+
* order the gate ranked them. Each named id is resolved to the memory that
|
|
1645
|
+
* holds now (`headOf`), then held to what the turn could have shown at all
|
|
1646
|
+
* (`recallableRow`: not removed, archived, superseded, the self page, a
|
|
1647
|
+
* handoff, a card or a belief; not below reach) and to what it would not
|
|
1648
|
+
* show again (already shown this turn or this session, written by this
|
|
1649
|
+
* session, another project's under `RECALL_BY_PROJECT`, habituated, or a
|
|
1650
|
+
* candidate the gate inhibited). One per shown memory, `SEE_ALSO_MAX` a
|
|
1651
|
+
* turn. Reads only; the caller records.
|
|
1652
|
+
*/
|
|
1653
|
+
/** A memory id anywhere in a text, as the store mints them. */
|
|
1654
|
+
const NAMED_ID = /\bmem_[0-9a-f]{12,16}\b/g;
|
|
1655
|
+
|
|
1656
|
+
/** How many named ids one shown memory's text is read for: bounded reads on a
|
|
1657
|
+
* text that names many. The first that may ride along is the one. */
|
|
1658
|
+
export const SEE_ALSO_NAMES_READ = 4;
|
|
1659
|
+
|
|
1660
|
+
/** Verdicts that mean the turn would not show the memory whatever named it. */
|
|
1661
|
+
const HELD: ReadonlySet<Verdict> = new Set<Verdict>(["inhibited", "echo-skipped", "project-skipped", "dedup-suppressed"]);
|
|
1662
|
+
|
|
1663
|
+
/** The ids a text names, first mention first, each once. */
|
|
1664
|
+
export function namedIds(text: string): string[] {
|
|
1665
|
+
const out: string[] = [];
|
|
1666
|
+
for (const m of text.matchAll(NAMED_ID)) if (!out.includes(m[0])) out.push(m[0]);
|
|
1667
|
+
return out;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
export interface SeeAlsoInput {
|
|
1671
|
+
readonly store: Store;
|
|
1672
|
+
readonly day: number;
|
|
1673
|
+
/** What the turn shows, ids in render order (loud, then footnotes). */
|
|
1674
|
+
readonly shown: readonly string[];
|
|
1675
|
+
/** Of `shown`, the ones whose text is read: loud and cued footnotes. */
|
|
1676
|
+
readonly namers: readonly string[];
|
|
1677
|
+
/** Every candidate of the turn, by id (its doc, its verdict). */
|
|
1678
|
+
readonly candidates: ReadonlyMap<string, Candidate>;
|
|
1679
|
+
readonly verdicts: readonly CandidateVerdict[];
|
|
1680
|
+
/** This session's earlier showings. */
|
|
1681
|
+
readonly seen: Readonly<Record<string, unknown>>;
|
|
1682
|
+
readonly echo?: ReadonlySet<string>;
|
|
1683
|
+
/** Another project's work, when `RECALL_BY_PROJECT` holds it back. */
|
|
1684
|
+
readonly elsewhere?: (id: string) => boolean;
|
|
1685
|
+
readonly habituated?: ReadonlyMap<string, number>;
|
|
1686
|
+
readonly background: number;
|
|
1687
|
+
readonly t: RecallTunables;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
export interface SeeAlso {
|
|
1691
|
+
readonly id: string;
|
|
1692
|
+
/** The shown memory whose text named it. */
|
|
1693
|
+
readonly by: string;
|
|
1694
|
+
readonly doc: ProseDoc;
|
|
1695
|
+
/** Its verdict as shown: footnoted, via `see-also`. */
|
|
1696
|
+
readonly verdict: CandidateVerdict;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
/** The memories this turn's shown ones bring along. Never throws: a failure brings none. */
|
|
1700
|
+
export function seeAlso(input: SeeAlsoInput): SeeAlso[] {
|
|
1701
|
+
const { store, t } = input;
|
|
1702
|
+
if (!t.SEE_ALSO_NAMED_IDS || !(t.SEE_ALSO_MAX >= 1)) return [];
|
|
1703
|
+
const max = Math.floor(t.SEE_ALSO_MAX);
|
|
1704
|
+
const out: SeeAlso[] = [];
|
|
1705
|
+
try {
|
|
1706
|
+
const taken = new Set<string>(input.shown);
|
|
1707
|
+
const verdictOf = new Map(input.verdicts.map((v) => [v.id, v]));
|
|
1708
|
+
let denied: Set<string> | null = null;
|
|
1709
|
+
for (const by of input.namers) {
|
|
1710
|
+
if (out.length >= max) break;
|
|
1711
|
+
const doc = input.candidates.get(by)?.doc;
|
|
1712
|
+
if (doc === undefined) continue;
|
|
1713
|
+
const names = namedIds(`${doc.title ?? ""}\n${doc.body}`).filter((id) => id !== by).slice(0, SEE_ALSO_NAMES_READ);
|
|
1714
|
+
for (const named of names) {
|
|
1715
|
+
const id = headOf(store, named) ?? named;
|
|
1716
|
+
if (taken.has(id) || id === by) continue;
|
|
1717
|
+
if (input.seen[id] !== undefined || input.echo?.has(id) === true || input.habituated?.has(id) === true) continue;
|
|
1718
|
+
if (input.elsewhere?.(id) === true) continue;
|
|
1719
|
+
const prior = verdictOf.get(id);
|
|
1720
|
+
if (prior !== undefined && HELD.has(prior.verdict)) continue;
|
|
1721
|
+
denied ??= new Set(store.deniedIds());
|
|
1722
|
+
const row = recallableRow(store, id, { denied, ambient: true, day: input.day });
|
|
1723
|
+
if (row === undefined || row === "below-reach") continue;
|
|
1724
|
+
const cand = input.candidates.get(id);
|
|
1725
|
+
const physics = cand?.physics ?? rowToPhysics(row);
|
|
1726
|
+
const verdict: CandidateVerdict =
|
|
1727
|
+
prior !== undefined
|
|
1728
|
+
? { ...prior, verdict: "footnoted", trains: true, via: "see-also", seeAlso: { by } }
|
|
1729
|
+
: {
|
|
1730
|
+
id,
|
|
1731
|
+
kind: row.kind as Kind,
|
|
1732
|
+
verdict: "footnoted",
|
|
1733
|
+
activation: 0,
|
|
1734
|
+
cue: 0,
|
|
1735
|
+
temporal: 0,
|
|
1736
|
+
semantic: 0,
|
|
1737
|
+
arrival: 0,
|
|
1738
|
+
hops: 0,
|
|
1739
|
+
cueFraction: 0,
|
|
1740
|
+
sal: gatedSal(physics, false),
|
|
1741
|
+
strength: strength(physics, input.day),
|
|
1742
|
+
// An id is an address, not an ambiguous handle: a use of what
|
|
1743
|
+
// it brought is a use like any other, and it trains.
|
|
1744
|
+
trains: true,
|
|
1745
|
+
bar: input.background,
|
|
1746
|
+
via: "see-also",
|
|
1747
|
+
seeAlso: { by },
|
|
1748
|
+
};
|
|
1749
|
+
out.push({ id, by, doc: cand?.doc ?? store.readProse(id), verdict });
|
|
1750
|
+
taken.add(id);
|
|
1751
|
+
break;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
return out;
|
|
1755
|
+
} catch {
|
|
1756
|
+
return [];
|
|
1757
|
+
}
|
|
1758
|
+
}
|