counterparts 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/package.json +1 -1
  3. package/src/adapters/claude-code/NOTES.md +12 -0
  4. package/src/adapters/claude-code/bin/hook.ts +85 -22
  5. package/src/adapters/claude-code/config.ts +7 -0
  6. package/src/adapters/claude-code/doctor.ts +20 -4
  7. package/src/adapters/claude-code/hooks.ts +157 -6
  8. package/src/adapters/claude-code/index.ts +3 -0
  9. package/src/adapters/cli/commands.ts +11 -0
  10. package/src/adapters/cli/mechanisms.ts +46 -21
  11. package/src/adapters/dashboard/registries.ts +4 -0
  12. package/src/adapters/dashboard/web/README.md +19 -11
  13. package/src/adapters/dashboard/web/flow.ts +2 -0
  14. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +9 -5
  15. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +6 -3
  16. package/src/adapters/dashboard/web/narrate.ts +8 -0
  17. package/src/adapters/dashboard/web/pages/health/sections/checks.js +17 -1
  18. package/src/adapters/dashboard/web/pages/self/index.js +55 -16
  19. package/src/adapters/dashboard/web/pages/self/sections/journal.js +75 -19
  20. package/src/adapters/dashboard/web/pages/self/sections/page.js +108 -65
  21. package/src/adapters/dashboard/web/pages/self/sections/settling.js +94 -99
  22. package/src/adapters/dashboard/web/pages/self/sections/wake.js +31 -15
  23. package/src/adapters/dashboard/web/pages/self/self.css +119 -59
  24. package/src/adapters/dashboard/web/pages/self/state.js +23 -0
  25. package/src/adapters/dashboard/web/pages/self/tips.js +50 -0
  26. package/src/adapters/dashboard/web/shared/memory-modal.js +9 -0
  27. package/src/adapters/dashboard/web/views/mechanisms.ts +85 -14
  28. package/src/adapters/dashboard/web/views/memory.ts +15 -1
  29. package/src/adapters/dashboard/web/views/mind.ts +130 -6
  30. package/src/adapters/feelings-line.ts +74 -0
  31. package/src/adapters/fired.ts +78 -18
  32. package/src/adapters/mcp/CONTRACT.md +8 -0
  33. package/src/adapters/mcp/NOTES.md +45 -0
  34. package/src/adapters/mcp/server.ts +165 -6
  35. package/src/adapters/mcp/tools.ts +51 -4
  36. package/src/core/bridge.ts +21 -16
  37. package/src/core/counterpart.ts +309 -6
  38. package/src/core/encode/CONTRACT.md +7 -1
  39. package/src/core/feelings-wheel.ts +171 -13
  40. package/src/core/mint.ts +9 -0
  41. package/src/core/physics/CONTRACT.md +43 -0
  42. package/src/core/physics/NOTES.md +94 -0
  43. package/src/core/physics/index.ts +98 -6
  44. package/src/core/prospective/CONTRACT.md +35 -6
  45. package/src/core/prospective/INTERFACE-GAPS.md +10 -5
  46. package/src/core/prospective/NOTES.md +175 -4
  47. package/src/core/prospective/derive.ts +32 -3
  48. package/src/core/prospective/index.ts +362 -39
  49. package/src/core/prospective/tunables.ts +18 -1
  50. package/src/core/prospective/windows.ts +104 -46
  51. package/src/core/recall/CONTRACT.md +28 -0
  52. package/src/core/recall/NOTES.md +39 -0
  53. package/src/core/recall/activate.ts +32 -5
  54. package/src/core/recall/gate.ts +7 -1
  55. package/src/core/recall/index.ts +19 -0
  56. package/src/core/recall/mood.ts +106 -0
  57. package/src/core/recall/tunables.ts +26 -0
  58. package/src/core/remember/index.ts +1 -0
  59. package/src/core/remember/proposals.ts +86 -3
  60. package/src/core/self/identity.ts +20 -1
  61. package/src/core/store/CONTRACT.md +9 -2
  62. package/src/core/store/NOTES.md +20 -0
  63. package/src/core/store/feelings.ts +23 -6
  64. package/src/core/store/index.ts +107 -10
  65. package/src/core/store/operational.ts +15 -1
  66. package/src/core/types.ts +9 -0
@@ -46,7 +46,8 @@ import { mintProposal } from "./mint.js";
46
46
  import type { MintResult } from "./mint.js";
47
47
  import { isObserver } from "./observer.js";
48
48
  import type { Stance } from "./observer.js";
49
- import { Prospective } from "./prospective/index.js";
49
+ import { Prospective, DATE_LINEAGE_MAX, DATE_MOVED_TO_META, cueModeOf } from "./prospective/index.js";
50
+ import type { PlainDue } from "./prospective/index.js";
50
51
  import {
51
52
  Recall,
52
53
  isConfidential,
@@ -764,6 +765,16 @@ export type DepositReason =
764
765
  | "gate-failed"
765
766
  | "io-failed";
766
767
 
768
+ /**
769
+ * One plain reminder, claimed and due to be told (`Counterpart.plainReminders`).
770
+ * The record `prospective/` hands out, plus `what`: the memory's title or its
771
+ * first line, which is the one piece of the memory's own words a host needs to
772
+ * say it. The sentence around it is the host's.
773
+ */
774
+ export interface PlainReminder extends PlainDue {
775
+ readonly what: string;
776
+ }
777
+
767
778
  export interface DepositResult {
768
779
  readonly deposited: boolean;
769
780
  readonly reason: DepositReason;
@@ -778,6 +789,35 @@ export interface DepositResult {
778
789
  * …), when that is why it was refused. A bare "malformed" told the author
779
790
  * nothing to fix (IMPROVEMENTS U11). */
780
791
  readonly malformed?: MalformedReason | null;
792
+ /**
793
+ * Present when this deposit REVISED a dated memory (`updates:`, declared and
794
+ * resolved): the reminder the new memory carries after the carry-over, and
795
+ * where it came from (`Counterpart#carryReminder`, review N7).
796
+ */
797
+ readonly reminder?: DepositReminder;
798
+ }
799
+
800
+ /** A revision's reminder: carried over, replaced, or dropped — and moved. */
801
+ export interface DepositReminder {
802
+ /** The memory the reminder came from — the one revised, or, when its reminder
803
+ * had already moved on, the memory holding it now. Its own date was cleared
804
+ * (kept in its version) when `moved`. */
805
+ readonly from: string;
806
+ /** The date the new memory carries, or null when the revision dropped it. */
807
+ readonly eventDate: string | null;
808
+ readonly remind: "plain" | "quiet" | null;
809
+ /** Which fields came from `from` because the author left them out. */
810
+ readonly inherited: readonly ("eventDate" | "remind")[];
811
+ /** False only when clearing `from`'s date failed (evented). */
812
+ readonly moved: boolean;
813
+ }
814
+
815
+ /** `carryReminder`'s answer: the proposal to mint, and what it took from where. */
816
+ interface ReminderCarryPlan {
817
+ readonly proposal: Proposal;
818
+ /** The dated memory being revised, or null when there is nothing to carry. */
819
+ readonly from: string | null;
820
+ readonly inherited: readonly ("eventDate" | "remind")[];
781
821
  }
782
822
 
783
823
  export interface SweepEntry {
@@ -1184,6 +1224,8 @@ export const RECALL_DECISION_FIELDS = [
1184
1224
  "footnoteCount",
1185
1225
  "affectFlag",
1186
1226
  "affectReason",
1227
+ // Emotion part A (2026-09-26): admitted memories the current mood lifted.
1228
+ "moodMatched",
1187
1229
  "sentinelRendered",
1188
1230
  "surfaced",
1189
1231
  "footnotes",
@@ -1254,6 +1296,7 @@ function recallDecisionRecord(
1254
1296
  footnoteCount: d.footnotes.length,
1255
1297
  affectFlag: d.affectFlag,
1256
1298
  affectReason: d.affectReason,
1299
+ moodMatched: d.moodMatched,
1257
1300
  sentinelRendered: d.sentinel !== null,
1258
1301
  surfaced: tierRows(d.surfaced, d.verdicts),
1259
1302
  footnotes: tierRows(d.footnotes, d.verdicts),
@@ -1282,6 +1325,9 @@ export class Counterpart {
1282
1325
 
1283
1326
  /** Undefined when no embedder was wired, and under observer. See below. */
1284
1327
  private readonly vectors: VectorSource | undefined;
1328
+ /** The owner's own session? Recall's rule, kept for the plain lane: a
1329
+ * confidential memory is said only to its owner (recall §9.1 G5). */
1330
+ private readonly owner: boolean;
1285
1331
  private reportedBudget: number | null;
1286
1332
  private readonly onEvent: ((e: CounterpartEvent) => void) | undefined;
1287
1333
  private readonly nowFn: () => number;
@@ -1312,6 +1358,7 @@ export class Counterpart {
1312
1358
  // belongs in `Store.open` too, and this is not a substitute for that.
1313
1359
  if (opts.dir !== undefined) assertSafeDataDir(opts.dir);
1314
1360
  this.observer = isObserver(opts);
1361
+ this.owner = opts.owner === true && !this.observer;
1315
1362
  this.onEvent = opts.onEvent;
1316
1363
  this.nowFn = opts.now ?? ((): number => Date.now());
1317
1364
  this.reportedBudget = opts.budgetBytes ?? null;
@@ -1644,17 +1691,148 @@ export class Counterpart {
1644
1691
  * temporal cues from `prospective/`, the hop function from `associate/`. A
1645
1692
  * missing `at` means no temporal channel — a lived day is not a date.
1646
1693
  */
1647
- recallForTurn(turn: RecallTurn, opts: { at?: string } = {}): RecallResult {
1648
- const result = recallTurn(this.recall, this.withSemantic(turn), {
1694
+ recallForTurn(
1695
+ turn: RecallTurn,
1696
+ opts: {
1697
+ at?: string;
1698
+ /** Memory ids whose temporal cue is held back THIS turn: plain items the
1699
+ * host is saying outright in the same breath (2026-09-26 review), so the
1700
+ * model is not handed the same date twice in one turn. */
1701
+ withhold?: ReadonlySet<string>;
1702
+ } = {},
1703
+ ): RecallResult {
1704
+ // THE TEMPORAL CUES ARE COMPUTED HERE, not inside `composeTurn`, for one
1705
+ // reason: the window each one came from has to survive the turn, so the
1706
+ // arrivals the gate actually admitted can SPEND their fire budget below.
1707
+ // `composeTurn` skips its own read when `turn.temporal` is already set, so
1708
+ // this is the same channel and the same ceiling (§12 G1, G5) — one read of
1709
+ // `arrivals()`, never two.
1710
+ const arrived =
1711
+ opts.at === undefined || turn.temporal !== undefined
1712
+ ? null
1713
+ : this.prospective.arrivals({
1714
+ at: opts.at,
1715
+ ...(turn.day === undefined ? {} : { day: turn.day }),
1716
+ sessionId: turn.sessionId,
1717
+ }).arrivals.filter((a) => opts.withhold?.has(a.memoryId) !== true);
1718
+ const withCues: RecallTurn =
1719
+ arrived === null ? turn : { ...turn, temporal: arrived.map((a) => ({ id: a.memoryId, weight: a.cueWeight })) };
1720
+ const result = recallTurn(this.recall, this.withSemantic(withCues), {
1649
1721
  schemas: this.schemas,
1650
1722
  prospective: this.prospective,
1651
1723
  associate: this.associate,
1652
1724
  ...(opts.at === undefined ? {} : { at: opts.at }),
1653
1725
  });
1654
1726
  this.recordDecision(result.decision, opts.at ?? null);
1727
+ if (arrived !== null && opts.at !== undefined) this.spendArrivals(arrived, result.decision, opts.at);
1655
1728
  return result;
1656
1729
  }
1657
1730
 
1731
+ /**
1732
+ * `Prospective.fire()`'s LIVE CALLER (2026-09-26; until today the only one was
1733
+ * `tools/demo/seed.ts`, so a dated memory would have been re-offered every
1734
+ * turn of its window). A fire is a surfacing that HAPPENED (prospective NOTES
1735
+ * §6): an arrival is spent only when the gate put its memory in this turn's
1736
+ * surfaced or footnoted set — which is what makes brake 1 (once per lived
1737
+ * day) and brake 2 (`FIRES_PER_WINDOW`) real. An aborted turn surfaced
1738
+ * nothing and spends nothing (recall §5 G2); an observer's `fire()` stands
1739
+ * down on its own (§5 G9). Never throws into the turn: a lost fire row costs
1740
+ * one extra polite mention, never the recall (§12 G12).
1741
+ */
1742
+ private spendArrivals(
1743
+ arrived: readonly { memoryId: string; windowKey: string }[],
1744
+ decision: RecallDecision,
1745
+ at: string,
1746
+ ): void {
1747
+ if (decision.aborted || arrived.length === 0) return;
1748
+ const shown = new Set<string>([...decision.surfaced, ...decision.footnotes]);
1749
+ for (const a of arrived) {
1750
+ if (!shown.has(a.memoryId)) continue;
1751
+ try {
1752
+ this.prospective.fire({
1753
+ memoryId: a.memoryId,
1754
+ windowKey: a.windowKey,
1755
+ at,
1756
+ day: decision.day,
1757
+ sessionId: decision.sessionId,
1758
+ });
1759
+ } catch (err) {
1760
+ this.emit("counterpart.prospective.fire.failed", a.memoryId, { code: errCode(err) });
1761
+ }
1762
+ }
1763
+ }
1764
+
1765
+ /**
1766
+ * PLAIN REMINDERS DUE TODAY, NOT YET CLAIMED — a read. The owner-decided
1767
+ * exception to "a cue, not a command" (prospective CONTRACT §3): an item its
1768
+ * author marked plain is SAID on its day, to the person and to the model,
1769
+ * once per beat. A host that can tell whether its line will actually reach
1770
+ * the person reads here and claims (`claimPlainReminder`) only what it is
1771
+ * certainly about to show — "mark only what is certainly leaving", the
1772
+ * update notice's rule (2026-09-26 review). `plainReminders` is the two in
1773
+ * one, for a host with no such question.
1774
+ *
1775
+ * `what` is the memory's title, else the first line of its body, with its
1776
+ * whitespace folded — the handle a person recognizes. How long a line may be
1777
+ * and the sentence around it are the host adapter's to decide. Never throws:
1778
+ * any failure is an empty list.
1779
+ */
1780
+ plainDueToday(input: { at: string }): PlainReminder[] {
1781
+ if (this.observer) return [];
1782
+ const out: PlainReminder[] = [];
1783
+ try {
1784
+ for (const due of this.prospective.plainDue({ at: input.at })) {
1785
+ let what = "";
1786
+ try {
1787
+ const read = this.store.read(due.memoryId);
1788
+ // Confidential is said only in the owner's own session — recall's
1789
+ // boundary gate 1, which a line outside recall must keep by hand.
1790
+ if (read.confidential && !this.owner) continue;
1791
+ const doc = read.doc;
1792
+ const title = doc.title?.trim() ?? "";
1793
+ const line = doc.body.split("\n").map((l) => l.trim()).find((l) => l.length > 0) ?? "";
1794
+ what = (title.length > 0 ? title : line).replace(/\s+/g, " ").trim();
1795
+ } catch {
1796
+ continue;
1797
+ }
1798
+ if (what.length === 0) continue;
1799
+ out.push({ ...due, what });
1800
+ }
1801
+ } catch (err) {
1802
+ this.emit("counterpart.prospective.plain.failed", undefined, { code: errCode(err) });
1803
+ }
1804
+ return out;
1805
+ }
1806
+
1807
+ /**
1808
+ * Claim one plain beat: TRUE only when this call wrote the latch
1809
+ * (`Prospective.claimPlain`), so two processes racing for the same beat
1810
+ * cannot both show it. Show the line only on true. Never throws.
1811
+ */
1812
+ claimPlainReminder(reminder: PlainDue, input: { at: string; day?: number }): boolean {
1813
+ if (this.observer) return false;
1814
+ try {
1815
+ return this.prospective.claimPlain(reminder, {
1816
+ at: input.at,
1817
+ ...(input.day === undefined ? {} : { day: input.day }),
1818
+ });
1819
+ } catch (err) {
1820
+ this.emit("counterpart.prospective.plain.failed", reminder.memoryId, { code: errCode(err) });
1821
+ return false;
1822
+ }
1823
+ }
1824
+
1825
+ /**
1826
+ * PLAIN REMINDERS DUE TODAY, each already CLAIMED (`plainDueToday`, then
1827
+ * `claimPlainReminder` on each) — so the caller shows every one it gets
1828
+ * back, and a second process asking the same morning gets none. For a host
1829
+ * that shows whatever it reads; the Claude Code hooks instead claim only
1830
+ * what their envelope will carry (`bin/hook.ts#deliverTurn`).
1831
+ */
1832
+ plainReminders(input: { at: string; day?: number }): PlainReminder[] {
1833
+ return this.plainDueToday({ at: input.at }).filter((r) => this.claimPlainReminder(r, input));
1834
+ }
1835
+
1658
1836
  /**
1659
1837
  * THE FOURTH BORROWED CHANNEL, and the one that had no wiring: the lagged
1660
1838
  * semantic cue.
@@ -2178,8 +2356,9 @@ export class Counterpart {
2178
2356
  * Feelings on a memory (schema v7, `store/feelings.ts`), through the SECRETS
2179
2357
  * half of the battery: `carried_by` and an `other` word are words about the
2180
2358
  * moment, and a credential must not land in them any more than in a body.
2181
- * Nothing else here reads them — salience, decay and recall are untouched
2182
- * until the emotion build. Throws what the store throws (`FEELING_INVALID`).
2359
+ * Once stored they weigh (emotion part A): physics reads the strongest one
2360
+ * beside the row (§5.10) and recall reads recent ones as the mood (G18).
2361
+ * Throws what the store throws (`FEELING_INVALID`).
2183
2362
  */
2184
2363
  addFeelings(memoryId: string, inputs: readonly FeelingInput[], opts: { model?: string } = {}): AddFeelingsResult {
2185
2364
  const clean = inputs.map((f) => ({
@@ -3543,13 +3722,17 @@ export class Counterpart {
3543
3722
  return { ...none(reason, result.gate), malformed: result.malformed };
3544
3723
  }
3545
3724
 
3546
- const proposal = result.proposal;
3725
+ const carry = this.carryReminder(result.proposal);
3726
+ const proposal = carry.proposal;
3547
3727
  const mint = mintProposal(this.store, proposal, {
3548
3728
  self: this.self,
3549
3729
  channel: "authored",
3550
3730
  ...(ctx.model === undefined ? {} : { model: ctx.model }),
3551
3731
  onEvent: (name, data) => this.emit(name, undefined, data),
3552
3732
  });
3733
+ // BEFORE the revision dispatch: a current-state target is superseded there,
3734
+ // and the date must leave the row while it is still the live one.
3735
+ const reminder = carry.from === null ? null : this.moveReminder(carry, mint.id);
3553
3736
  this.emit("counterpart.deposit", mint.id, {
3554
3737
  source,
3555
3738
  kind: proposal.kind,
@@ -3574,6 +3757,121 @@ export class Counterpart {
3574
3757
  mint,
3575
3758
  gate: null,
3576
3759
  covers: proposal.covers,
3760
+ ...(reminder === null ? {} : { reminder }),
3761
+ };
3762
+ }
3763
+
3764
+ /**
3765
+ * A REVISION OWNS THE REMINDER (review N7, 2026-09-26). A `note` or a
3766
+ * `session_end` entry that revises a DATED memory (`updates:`) and leaves the
3767
+ * date out would otherwise mint an undated successor — and because a revision
3768
+ * of an ordinary memory is link-only (`revision.ts`), the old row would keep
3769
+ * its date and keep coming back beside the new one; a reschedule would leave
3770
+ * the old day firing too. So, field by field: what the author sent wins,
3771
+ * `eventDate: null` drops the date, and anything left out is carried over from
3772
+ * the memory being revised. `moveReminder` then clears the old row's date.
3773
+ *
3774
+ * Only for an address the AUTHOR declared and the store resolved (`declared`).
3775
+ * A content match is the engine's guess, and moving a date off a guessed row
3776
+ * would be a wrong write; leaving it where it is loses nothing. The sweep
3777
+ * builds its proposals without a `dateIntent`, so it carries nothing either
3778
+ * (it never dates a memory — `applySweep`).
3779
+ *
3780
+ * The reminder is found where it NOW lives (`reminderHolder`): the old id
3781
+ * stays live after a move, so "cancel it" or "it moved to the 20th" sent
3782
+ * against the id the model first saw must reach the memory holding the date,
3783
+ * not answer from a row whose date already left (review of #247). An
3784
+ * ARCHIVED holder carries nothing, as `revision.ts` refuses `target-archived`:
3785
+ * a reminder that faded or was put away is not revived onto a live row by a
3786
+ * revision that did not ask for it.
3787
+ */
3788
+ private carryReminder(p: Proposal): ReminderCarryPlan {
3789
+ const intent = p.dateIntent;
3790
+ const target = p.updates?.method === "declared" ? p.updates.resolved : null;
3791
+ const none: ReminderCarryPlan = { proposal: p, from: null, inherited: [] };
3792
+ if (intent === undefined || target === null) return none;
3793
+ const from = this.reminderHolder(target);
3794
+ // Nothing dated to carry or to move: the author's own fields stand as sent.
3795
+ if (from === null) return none;
3796
+ const priorDate = this.store.row(from)?.event_date ?? null;
3797
+ if (priorDate === null) return none;
3798
+ let priorMode: "plain" | "quiet" = "quiet";
3799
+ try {
3800
+ priorMode = cueModeOf(this.store.readProse(from));
3801
+ } catch {
3802
+ // Unreadable prose: the date still carries, at the default mode.
3803
+ }
3804
+ const eventDate =
3805
+ intent.eventDate === "set" ? p.eventDate : intent.eventDate === "cleared" ? null : priorDate;
3806
+ const remind = eventDate === null ? null : intent.remind ?? priorMode;
3807
+ const inherited: ("eventDate" | "remind")[] = [];
3808
+ if (eventDate !== null && intent.eventDate === "absent") inherited.push("eventDate");
3809
+ if (eventDate !== null && intent.remind === null) inherited.push("remind");
3810
+ return { proposal: { ...p, eventDate, remind, reminderFrom: from }, from, inherited };
3811
+ }
3812
+
3813
+ /**
3814
+ * The live memory holding the reminder `target` had: `target` itself when it
3815
+ * is dated, else the end of its `meta.reminderMovedTo` chain (each hop through
3816
+ * `Store#resolve`, since a holder can itself be superseded). Null when there
3817
+ * is none, when the chain reaches an archived or removed row, or when it runs
3818
+ * past `DATE_LINEAGE_MAX`.
3819
+ */
3820
+ private reminderHolder(target: string): string | null {
3821
+ let current = target;
3822
+ const seen = new Set<string>();
3823
+ for (let hop = 0; hop <= DATE_LINEAGE_MAX; hop++) {
3824
+ if (seen.has(current)) return null;
3825
+ seen.add(current);
3826
+ const row = this.store.row(current);
3827
+ if (row === undefined || row.archived === 1) return null;
3828
+ if (row.event_date !== null) return current;
3829
+ let next: unknown;
3830
+ try {
3831
+ next = this.store.readProse(current).meta[DATE_MOVED_TO_META];
3832
+ if (typeof next !== "string") return null;
3833
+ current = this.store.resolve(next);
3834
+ } catch {
3835
+ return null;
3836
+ }
3837
+ }
3838
+ return null;
3839
+ }
3840
+
3841
+ /**
3842
+ * The other half of `carryReminder`: the revised row's date is cleared, so the
3843
+ * reminder lives on exactly one memory — the newest. `Store#revise` keeps the
3844
+ * old date in the version it writes (constitution 7). A failed clear does not
3845
+ * fail a deposit that is already on disk; it is emitted and reported.
3846
+ */
3847
+ private moveReminder(carry: ReminderCarryPlan, successor: string): DepositReminder {
3848
+ const from = carry.from as string;
3849
+ let moved = false;
3850
+ try {
3851
+ // The forward pointer rides the same revise, so the clear and the address
3852
+ // it leaves behind land in one transaction or not at all.
3853
+ this.store.revise(from, {
3854
+ eventDate: null,
3855
+ meta: { [DATE_MOVED_TO_META]: successor },
3856
+ reason: "reminder-moved",
3857
+ });
3858
+ moved = true;
3859
+ } catch (err) {
3860
+ this.emit("counterpart.reminder.move.failed", from, { successor, error: errCode(err) });
3861
+ }
3862
+ this.emit("counterpart.reminder.moved", successor, {
3863
+ from,
3864
+ moved,
3865
+ eventDate: carry.proposal.eventDate,
3866
+ remind: carry.proposal.remind,
3867
+ inherited: carry.inherited.join(",") || null,
3868
+ });
3869
+ return {
3870
+ from,
3871
+ eventDate: carry.proposal.eventDate,
3872
+ remind: carry.proposal.remind,
3873
+ inherited: carry.inherited,
3874
+ moved,
3577
3875
  };
3578
3876
  }
3579
3877
 
@@ -3736,6 +4034,11 @@ export class Counterpart {
3736
4034
  aliases: [...accepted.aliases],
3737
4035
  updates,
3738
4036
  unresolved: accepted.unresolved,
4037
+ // The sweep never dates a memory: a reminder date is an explicit field
4038
+ // an AUTHOR writes, and the interpreter's retelling is not one (owner
4039
+ // decision 2026-09-25/26 — never infer a date from text).
4040
+ eventDate: null,
4041
+ remind: null,
3739
4042
  at: this.nowFn(),
3740
4043
  day,
3741
4044
  contentHash: accepted.contentHash,
@@ -51,7 +51,13 @@ a credential. It is a deliberate, non-ablatable addition.
51
51
  - **Beliefs and current state render verbatim; identity core renders compressed.** [v1]
52
52
  §8 G7 — "a paraphrase of a belief cannot be honestly confirmed or contradicted."
53
53
  - **Emotion is typed, attributed, and absent-means-null, never neutral. Retro-typing
54
- emotion is forbidden.** [v1] §4.2 G5.
54
+ emotion is forbidden.** [v1] §4.2 G5. *(2026-09-26, emotion part A: the author's
55
+ `emotional` dimension is now read by the battery when it is given ALONE — a missing
56
+ relevance or predictive reads 0, as `mint.ts` has always stored it — so the two
57
+ readings of one note agree. That is the author's own number, not a type inferred here;
58
+ the stated-emotion gate still yields no magnitude. The emotional weight a memory
59
+ carries — its score or its recorded feelings, whichever is stronger — is physics'
60
+ arithmetic, §5.10.)*
55
61
  - **Task-state is not memory**, discriminated at encode time by one question: *would this
56
62
  still be a true memory worth holding after the date passes?* [v1] §4.2 G10.
57
63
 
@@ -22,8 +22,37 @@
22
22
  * **Valence** is +1 or −1 per entry, and 0 for `surprise` itself: surprise's
23
23
  * children take their own (amazed, awe, astonished, excited, energetic, eager
24
24
  * lean positive; startled, shocked, dismayed, confused, perplexed, disillusioned
25
- * lean negative). Nothing reads valence yet — it is here so the emotion build
26
- * that comes later does not have to re-transcribe the poster.
25
+ * lean negative). The one reader so far is the suggestion rule below: a word
26
+ * off the wheel is never nudged toward a word of the opposite sign.
27
+ *
28
+ * **ADDITIONS — NOT THE POSTER'S** (emotion part A, 2026-09-26). Real use
29
+ * showed the poster missing the words a counterpart actually reaches for:
30
+ * session random-53 wrote eight feelings and seven fell off the wheel
31
+ * (grateful, curious, tender, exposed, sheepish, caught, clarified — only
32
+ * "amused" matched). `ADDED` below lists the words added for that, each marked
33
+ * `added: true` on its entry and placed on the middle ring of its best core
34
+ * with no parent — they are not squeezed under a poster word they do not
35
+ * belong to. The poster's entries are unchanged, and `added` is how any reader
36
+ * tells the two apart.
37
+ *
38
+ * **BLENDS carry two cores** with no schema change: an entry may declare
39
+ * `alsoCore`. The stored row keeps the PRIMARY core (`core`); anything that
40
+ * matches by core — mood-matching in recall — reads a blend as both
41
+ * (`coresOfFeeling`), and a writer may name a blend under either of its cores.
42
+ * One poster word gains a second core this way (`vulnerable`, + fear, so
43
+ * "exposed" — its alias — can be written under fear); the word stays the
44
+ * poster's and the entry says the second core is ours (`secondCoreAdded`).
45
+ *
46
+ * **ALIASES** (`ALIASES`): a few everyday words that mean a wheel word read
47
+ * as that word (`exposed` → `vulnerable`, `thankful` → `grateful`). The caller
48
+ * is told what its word was read as.
49
+ *
50
+ * **Suggestions are only offered when genuinely close** (`closestKeys`): a
51
+ * misspelling (edit distance 1, or 2 for a word of six letters or more) of a
52
+ * word under the SAME core, never one of the opposite valence. The first
53
+ * version offered the five nearest keys by raw edit distance, so "tender"
54
+ * under sad was offered bored / despair / lonely — steering a warm word toward
55
+ * its opposite. A word with nothing close is simply kept as the writer's own.
27
56
  *
28
57
  * A leaf: no imports, so `store/` (which validates against it) and anything
29
58
  * above can read it without a layering question.
@@ -47,6 +76,13 @@ export interface WheelEntry {
47
76
  readonly valence: Valence;
48
77
  /** A middle-ring word the wheel ALSO prints on the outer ring of the same core. */
49
78
  readonly alsoUnder?: string;
79
+ /** True for a word added from real use — NOT on the owner's poster. See
80
+ * ADDITIONS in the header. */
81
+ readonly added?: true;
82
+ /** A blend's second core. The row stores `core`; matching reads both. */
83
+ readonly alsoCore?: CoreEmotion;
84
+ /** True when a POSTER word's `alsoCore` is ours, not the poster's. */
85
+ readonly secondCoreAdded?: true;
50
86
  }
51
87
 
52
88
  /** The one emotion key that is not on the wheel: the person's own word is kept beside it. */
@@ -107,6 +143,45 @@ const TREE: Record<CoreEmotion, readonly Branch[]> = {
107
143
 
108
144
  const SURPRISE_POSITIVE = new Set(["excited", "energetic", "eager", "amazed", "awe", "astonished"]);
109
145
 
146
+ /**
147
+ * THE ADDITIONS — words a counterpart actually has that the poster does not
148
+ * (session random-53, 2026-09-26). Each sits on the middle ring of its best
149
+ * core, marked `added`. A blend names its second core; its valence is stated
150
+ * rather than derived, because a blend's sign is not its primary core's.
151
+ * WORKING DEFAULTS: the placements are judgment, and the owner may move any.
152
+ */
153
+ const ADDED: readonly { word: string; core: CoreEmotion; alsoCore?: CoreEmotion; valence: Valence }[] = [
154
+ { word: "grateful", core: "happy", valence: 1 },
155
+ { word: "curious", core: "happy", valence: 1 },
156
+ { word: "intrigued", core: "happy", valence: 1 },
157
+ { word: "fond", core: "happy", valence: 1 },
158
+ { word: "relieved", core: "happy", valence: 1 },
159
+ { word: "moved", core: "happy", valence: 1 },
160
+ // Blends: the row keeps the first core, matching reads both.
161
+ { word: "bittersweet", core: "happy", alsoCore: "sad", valence: 0 },
162
+ { word: "tender", core: "sad", alsoCore: "happy", valence: 1 },
163
+ { word: "wistful", core: "sad", alsoCore: "happy", valence: -1 },
164
+ { word: "sheepish", core: "fear", alsoCore: "sad", valence: -1 },
165
+ ];
166
+
167
+ /** A second core given to a POSTER word — itself an addition, marked on the entry. */
168
+ const ADDED_SECOND_CORE: Readonly<Record<string, CoreEmotion>> = {
169
+ // Vulnerable is printed under sad (despair); being exposed is as much fear.
170
+ vulnerable: "fear",
171
+ };
172
+
173
+ /**
174
+ * Everyday words that MEAN a wheel word, read as it. Small on purpose: an
175
+ * alias decides for the writer, so each one must be a synonym, not a cousin.
176
+ */
177
+ export const ALIASES: Readonly<Record<string, string>> = {
178
+ exposed: "vulnerable",
179
+ thankful: "grateful",
180
+ touched: "moved",
181
+ nostalgic: "wistful",
182
+ inquiring: "curious",
183
+ };
184
+
110
185
  function valenceOf(core: CoreEmotion, word: string, ring: WheelRing): Valence {
111
186
  if (core === "happy") return 1;
112
187
  if (core !== "surprise") return -1;
@@ -156,8 +231,28 @@ function build(): WheelEntry[] {
156
231
  seen.add(key);
157
232
  }
158
233
  }
234
+ // The additions, after the poster's own words for this core.
235
+ for (const a of ADDED) {
236
+ if (a.core !== core) continue;
237
+ if (seen.has(a.word) || coresOf.has(a.word)) throw new Error(`feelings wheel: addition "${a.word}" is already on the poster`);
238
+ out.push({
239
+ key: a.word,
240
+ word: a.word,
241
+ core,
242
+ ring: "middle",
243
+ parent: null,
244
+ valence: a.valence,
245
+ added: true,
246
+ ...(a.alsoCore === undefined ? {} : { alsoCore: a.alsoCore }),
247
+ });
248
+ seen.add(a.word);
249
+ }
159
250
  }
160
- return out;
251
+ // A second core on a poster word is an addition too, and says so.
252
+ return out.map((e) => {
253
+ const second = ADDED_SECOND_CORE[e.key];
254
+ return second === undefined ? e : { ...e, alsoCore: second, secondCoreAdded: true as const };
255
+ });
161
256
  }
162
257
 
163
258
  /** Every entry on the wheel, cores first within each core's block. */
@@ -173,34 +268,97 @@ export function wheelEntry(key: string): WheelEntry | undefined {
173
268
  return BY_KEY.get(key);
174
269
  }
175
270
 
271
+ /**
272
+ * Every core a recorded feeling counts under: its own, plus a blend's second
273
+ * core. An `other` (or a key the wheel does not know) counts under the core it
274
+ * was recorded with, and nothing else.
275
+ */
276
+ export function coresOfFeeling(core: string, emotion: string): CoreEmotion[] {
277
+ const entry = BY_KEY.get(emotion);
278
+ const out: CoreEmotion[] = isCoreEmotion(core) ? [core] : [];
279
+ if (entry !== undefined) {
280
+ if (!out.includes(entry.core)) out.push(entry.core);
281
+ if (entry.alsoCore !== undefined && !out.includes(entry.alsoCore)) out.push(entry.alsoCore);
282
+ }
283
+ return out;
284
+ }
285
+
286
+ /** A blend may be named under either of its cores. */
287
+ function underCore(e: WheelEntry, core: CoreEmotion): boolean {
288
+ return e.core === core || e.alsoCore === core;
289
+ }
290
+
176
291
  /** How an emotion as given reads against the wheel, under the core it was given with. */
177
292
  export type EmotionResolution =
178
- | { readonly kind: "wheel"; readonly entry: WheelEntry }
293
+ /** On the wheel. `alias` is the writer's word when it was read AS this entry
294
+ * (`exposed` → `vulnerable`); absent when the word was the entry itself. */
295
+ | { readonly kind: "wheel"; readonly entry: WheelEntry; readonly alias?: string }
179
296
  | { readonly kind: "wrong-core"; readonly entry: WheelEntry }
180
297
  | { readonly kind: "other"; readonly word: string; readonly closest: readonly string[] };
181
298
 
182
299
  /**
183
300
  * Read `emotion` (a key or a bare word, any case) under `core`. A bare word the
184
- * wheel prints under two cores is qualified by `core`; a word that is on the
301
+ * wheel prints under two cores is qualified by `core`; a blend reads under
302
+ * either of its cores; an alias reads as its wheel word; a word that is on the
185
303
  * wheel under a DIFFERENT core only is `wrong-core`; anything else is `other`,
186
- * with the closest keys under `core` for the caller to rewrite with.
304
+ * with a suggestion only when one is genuinely close (`closestKeys`).
187
305
  */
188
306
  export function resolveEmotion(core: CoreEmotion, emotion: string): EmotionResolution {
189
307
  const raw = emotion.trim().toLowerCase();
190
308
  const direct = BY_KEY.get(raw) ?? BY_KEY.get(`${core}.${raw}`);
191
- if (direct !== undefined) return direct.core === core ? { kind: "wheel", entry: direct } : { kind: "wrong-core", entry: direct };
309
+ if (direct !== undefined) return underCore(direct, core) ? { kind: "wheel", entry: direct } : { kind: "wrong-core", entry: direct };
310
+ const aliased = Object.hasOwn(ALIASES, raw) ? BY_KEY.get(ALIASES[raw] as string) : undefined;
311
+ if (aliased !== undefined) {
312
+ return underCore(aliased, core) ? { kind: "wheel", entry: aliased, alias: emotion.trim() } : { kind: "wrong-core", entry: aliased };
313
+ }
192
314
  const elsewhere = FEELINGS_WHEEL.find((e) => e.word === raw);
193
315
  if (elsewhere !== undefined) return { kind: "wrong-core", entry: elsewhere };
194
316
  return { kind: "other", word: emotion.trim(), closest: closestKeys(core, raw) };
195
317
  }
196
318
 
197
- /** Up to `n` keys under `core`, nearest first by edit distance to `word`. */
198
- export function closestKeys(core: CoreEmotion, word: string, n = 5): string[] {
199
- return FEELINGS_WHEEL.filter((e) => e.core === core && e.ring !== "core")
200
- .map((e) => ({ key: e.key, d: editDistance(word, e.word) }))
201
- .sort((a, b) => a.d - b.d || (a.key < b.key ? -1 : 1))
319
+ /** The sign a core leans: happy up, surprise either way, the other four down. */
320
+ function coreSign(core: CoreEmotion): Valence {
321
+ return core === "happy" ? 1 : core === "surprise" ? 0 : -1;
322
+ }
323
+
324
+ /**
325
+ * At most `n` wheel keys that `word` is GENUINELY close to under `core` — and
326
+ * usually none. Close means a misspelling: edit distance 1, or 2 for a word of
327
+ * six letters or more, against a wheel word or an alias. Only words that can be
328
+ * written under `core` (its own, and blends that include it) are offered, and
329
+ * never one whose valence opposes the core's — a writer who chose `sad` is not
330
+ * steered to a happy word, nor the reverse. Nothing close: an empty list, and
331
+ * the writer's own word stands.
332
+ *
333
+ * Replaced 2026-09-26 the "five nearest keys by raw edit distance", which
334
+ * offered "tender" (under sad) bored, despair and lonely.
335
+ */
336
+ export function closestKeys(core: CoreEmotion, word: string, n = 3): string[] {
337
+ const w = word.trim().toLowerCase();
338
+ if (w.length === 0) return [];
339
+ const limit = w.length >= 6 ? 2 : 1;
340
+ const sign = coreSign(core);
341
+ const fits = (e: WheelEntry): boolean =>
342
+ e.ring !== "core" &&
343
+ underCore(e, core) &&
344
+ // A blend belongs to this core by definition; any other word must lean
345
+ // the core's way (surprise, sign 0, leans either).
346
+ (e.alsoCore !== undefined || sign === 0 || e.valence === 0 || e.valence === sign);
347
+ const best = new Map<string, number>();
348
+ const offer = (key: string, d: number): void => {
349
+ if (d > limit) return;
350
+ const had = best.get(key);
351
+ if (had === undefined || d < had) best.set(key, d);
352
+ };
353
+ for (const e of FEELINGS_WHEEL) if (fits(e)) offer(e.key, editDistance(w, e.word));
354
+ for (const [alias, key] of Object.entries(ALIASES)) {
355
+ const e = BY_KEY.get(key);
356
+ if (e !== undefined && fits(e)) offer(key, editDistance(w, alias));
357
+ }
358
+ return [...best.entries()]
359
+ .sort((a, b) => a[1] - b[1] || (a[0] < b[0] ? -1 : 1))
202
360
  .slice(0, n)
203
- .map((x) => x.key);
361
+ .map(([key]) => key);
204
362
  }
205
363
 
206
364
  function editDistance(a: string, b: string): number {