counterparts 0.3.11 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/docs/QUICKSTART.md +5 -0
  3. package/docs/README.md +2 -2
  4. package/docs/module-map.md +3 -3
  5. package/package.json +1 -1
  6. package/src/adapters/claude-code/CONTRACT.md +36 -10
  7. package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
  8. package/src/adapters/claude-code/NOTES.md +182 -0
  9. package/src/adapters/claude-code/bin/hook.ts +46 -12
  10. package/src/adapters/claude-code/bin/runner.ts +7 -1
  11. package/src/adapters/claude-code/doctor.ts +632 -18
  12. package/src/adapters/claude-code/hooks.ts +61 -16
  13. package/src/adapters/claude-code/index.ts +11 -0
  14. package/src/adapters/claude-code/night-run.ts +150 -14
  15. package/src/adapters/claude-code/transcript.ts +268 -1
  16. package/src/adapters/cli/CONTRACT.md +5 -0
  17. package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
  18. package/src/adapters/cli/NOTES.md +111 -0
  19. package/src/adapters/cli/commands.ts +134 -92
  20. package/src/adapters/cli/dream-core.ts +57 -42
  21. package/src/adapters/cli/export.ts +320 -21
  22. package/src/adapters/cli/help.ts +2 -1
  23. package/src/adapters/cli/index.ts +1 -0
  24. package/src/adapters/cli/install.ts +39 -7
  25. package/src/adapters/cli/mechanisms.ts +7 -1
  26. package/src/adapters/cli/uninstall.ts +13 -5
  27. package/src/adapters/cli/wire.ts +189 -63
  28. package/src/adapters/config.ts +2 -0
  29. package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
  30. package/src/adapters/dashboard/NOTES.md +79 -0
  31. package/src/adapters/dashboard/registries.ts +34 -2
  32. package/src/adapters/dashboard/web/README.md +19 -14
  33. package/src/adapters/dashboard/web/actions.ts +23 -1
  34. package/src/adapters/dashboard/web/flow.ts +14 -0
  35. package/src/adapters/dashboard/web/lanes.ts +10 -0
  36. package/src/adapters/dashboard/web/narrate.ts +88 -2
  37. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
  38. package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
  39. package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
  40. package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
  41. package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
  42. package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
  43. package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
  44. package/src/adapters/dashboard/web/server.ts +0 -5
  45. package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
  46. package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
  47. package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
  48. package/src/adapters/dashboard/web/views/health.ts +21 -3
  49. package/src/adapters/dashboard/web/views/search.ts +4 -45
  50. package/src/adapters/dashboard/web/views.ts +2 -2
  51. package/src/adapters/fired.ts +430 -28
  52. package/src/adapters/host-wiring.ts +300 -0
  53. package/src/adapters/hosts.ts +11 -0
  54. package/src/adapters/lifecycle.ts +42 -2
  55. package/src/adapters/log/index.ts +9 -0
  56. package/src/adapters/mcp/CONTRACT.md +151 -11
  57. package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
  58. package/src/adapters/mcp/NOTES.md +313 -1
  59. package/src/adapters/mcp/bin/serve.ts +74 -1
  60. package/src/adapters/mcp/deliberate.ts +169 -651
  61. package/src/adapters/mcp/facts.ts +1094 -0
  62. package/src/adapters/mcp/index.ts +25 -7
  63. package/src/adapters/mcp/meaning.ts +1610 -0
  64. package/src/adapters/mcp/server.ts +835 -150
  65. package/src/adapters/mcp/stdio.ts +3 -1
  66. package/src/adapters/mcp/stood-down.ts +51 -0
  67. package/src/adapters/mcp/tools.ts +167 -41
  68. package/src/adapters/plugin-run.sh +133 -0
  69. package/src/adapters/plugin.ts +329 -0
  70. package/src/adapters/sessions.ts +18 -4
  71. package/src/core/associate/CONTRACT.md +2 -1
  72. package/src/core/associate/INTERFACE-GAPS.md +6 -1
  73. package/src/core/associate/NOTES.md +45 -0
  74. package/src/core/briefing.ts +12 -3
  75. package/src/core/contradictions.ts +184 -0
  76. package/src/core/counterpart.ts +797 -51
  77. package/src/core/dream/CONTRACT.md +36 -4
  78. package/src/core/dream/INTERFACE-GAPS.md +29 -6
  79. package/src/core/dream/NOTES.md +107 -0
  80. package/src/core/dream/feeling-weeks.ts +198 -0
  81. package/src/core/dream/index.ts +109 -18
  82. package/src/core/dream/reflect.ts +346 -87
  83. package/src/core/dream/tunables.ts +24 -4
  84. package/src/core/encode/INTERFACE-GAPS.md +3 -1
  85. package/src/core/encode/NOTES.md +7 -0
  86. package/src/core/encode/words.ts +45 -0
  87. package/src/core/fit/INTERFACE-GAPS.md +8 -2
  88. package/src/core/fit/NOTES.md +39 -1
  89. package/src/core/fit/index.ts +40 -0
  90. package/src/core/handoff/CONTRACT.md +37 -2
  91. package/src/core/handoff/INTERFACE-GAPS.md +10 -0
  92. package/src/core/handoff/NOTES.md +72 -0
  93. package/src/core/handoff/index.ts +214 -12
  94. package/src/core/handoff/last-here.ts +6 -4
  95. package/src/core/mint.ts +12 -2
  96. package/src/core/physics/CONTRACT.md +14 -2
  97. package/src/core/physics/NOTES.md +33 -1
  98. package/src/core/physics/index.ts +28 -5
  99. package/src/core/prospective/CONTRACT.md +45 -6
  100. package/src/core/prospective/INTERFACE-GAPS.md +4 -0
  101. package/src/core/prospective/NOTES.md +138 -0
  102. package/src/core/prospective/derive.ts +33 -5
  103. package/src/core/prospective/index.ts +90 -5
  104. package/src/core/prospective/windows.ts +72 -1
  105. package/src/core/recall/CONTRACT.md +31 -12
  106. package/src/core/recall/INTERFACE-GAPS.md +28 -4
  107. package/src/core/recall/NOTES.md +70 -1
  108. package/src/core/recall/feeling-ask.ts +10 -1
  109. package/src/core/recall/index.ts +3 -1
  110. package/src/core/recall/probe.ts +58 -0
  111. package/src/core/recall/session.ts +46 -2
  112. package/src/core/recall/time-ask.ts +487 -0
  113. package/src/core/remember/CONTRACT.md +4 -1
  114. package/src/core/remember/INTERFACE-GAPS.md +9 -1
  115. package/src/core/remember/NOTES.md +8 -0
  116. package/src/core/remember/proposals.ts +47 -5
  117. package/src/core/revision.ts +18 -1
  118. package/src/core/schemas/CONTRACT.md +21 -1
  119. package/src/core/schemas/INTERFACE-GAPS.md +20 -2
  120. package/src/core/schemas/NOTES.md +144 -0
  121. package/src/core/schemas/aliases.ts +55 -5
  122. package/src/core/schemas/index.ts +93 -1
  123. package/src/core/schemas/types.ts +2 -0
  124. package/src/core/self/CONTRACT.md +32 -5
  125. package/src/core/self/INTERFACE-GAPS.md +7 -2
  126. package/src/core/self/NOTES.md +102 -1
  127. package/src/core/self/behind.ts +43 -3
  128. package/src/core/self/briefing.ts +12 -2
  129. package/src/core/self/chapter-address.ts +254 -0
  130. package/src/core/self/episodes.ts +27 -0
  131. package/src/core/self/index.ts +83 -8
  132. package/src/core/self/page.ts +88 -0
  133. package/src/core/self/tunables.ts +5 -0
  134. package/src/core/self/work.ts +35 -2
  135. package/src/core/self/writer.ts +30 -0
  136. package/src/core/sleep/INTERFACE-GAPS.md +22 -3
  137. package/src/core/sleep/NOTES.md +20 -1
  138. package/src/core/sleep/consolidate.ts +59 -7
  139. package/src/core/sleep/index.ts +3 -0
  140. package/src/core/sleep/prune.ts +6 -2
  141. package/src/core/sleep/types.ts +7 -0
  142. package/src/core/store/CONTRACT.md +16 -0
  143. package/src/core/store/NOTES.md +66 -0
  144. package/src/core/store/feelings.ts +14 -1
  145. package/src/core/store/index.ts +483 -16
  146. package/src/core/store/operational.ts +95 -2
  147. package/src/core/store/owner-op-seam.ts +23 -0
  148. package/src/core/time.ts +152 -0
  149. package/tools/install-loop/run.sh +48 -12
  150. package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
@@ -356,6 +356,13 @@ export interface PromotionRecord extends PromotionCrossing {
356
356
  * with that door closed it would not have crossed tonight.
357
357
  */
358
358
  readonly feelingRecordedLater?: boolean;
359
+ /**
360
+ * 2026-10-02 (review of #317): with `feelingRecordedLater`, whose later
361
+ * feeling could have carried it — a reflection's, an ordinary session's
362
+ * feeling-now (`awake`), or both. Absent on a record written before, or when
363
+ * the feelings could not be read: then it was a reflection's.
364
+ */
365
+ readonly feelingRecordedLaterBy?: readonly ("reflection" | "awake")[];
359
366
  }
360
367
 
361
368
  /** A prune record as persisted: physics' record, plus the id it belongs to. */
@@ -460,6 +460,22 @@ store property is the `VACUUM INTO`, and that is G19. The code's numbering wins.
460
460
  sets (1 otherwise); a settle never moves `last_used_day`. The owner's removal puts a
461
461
  standing settle back (fade, archive, closed flags) and then deletes the memory's pairs
462
462
  and their trail. The v10 migration carries every open dream flag onto an unsettled pair.
463
+ 26. **[M] The writer's three fields, and what a memory names** (schema v12, 2026-10-03;
464
+ working default, held lightly). `memories` and `versions` carry `occurred_on` (when the
465
+ thing happened: a calendar date as `time.ts` reads one — not `happened_on`, the lived
466
+ day of a write-up, and not `event_date`, a future reminder date), `said_by` (`SAID_BY`:
467
+ owner, self, inferred) and `status` (`STATUSES`: done, planned, proposed, asked). `put`
468
+ and `revise` write them; one that cannot be read writes NULL rather than refusing (the
469
+ doors drop them with a note first); a revise that does not name one keeps it, and the
470
+ version it writes keeps the words' own three. `supersede` / `supersedeInto` carry each
471
+ to a successor that was not given its own. `memory_subjects` links a memory to the
472
+ entity cards its title and body name (ids only, `via` write / birth / backfill), read
473
+ both ways (`subjectsOf`, `memoriesNaming`). The store does not know what a name is:
474
+ the composition root installs the finder (`findSubjectsWith`), and every memory `put`
475
+ and every revise of a memory's words relinks in the same transaction, fail-open. The
476
+ owner's removal blanks the three on the row and its versions and deletes the links
477
+ both ways, and a reflection entry's memory it redacts loses its links too. The migration adds the columns and the table and records its moment
478
+ (`V12_UPGRADE_KEY`); `OBSERVER_READ_FLOOR` stays 11.
463
479
 
464
480
  ## 6. Scars honored
465
481
 
@@ -1903,3 +1903,69 @@ store does with it:
1903
1903
  - **Open: the store's own unit tests still run under Bun only.** They import `bun:test`;
1904
1904
  porting them was not cheap, so the Node smoke test covers the binding end to end
1905
1905
  instead.
1906
+
1907
+ ## 2026-10-02 — lane B: an `awake` feeling source, and a merge keeps a feeling's moment
1908
+
1909
+ - **`awake`** joins `FEELING_SOURCES` (no schema change; the column is TEXT): a later
1910
+ feeling recorded in an ordinary session (`dream/reflect.ts#feelAgain`). It is a later
1911
+ feeling like a reflection's — `recorded_later` set — and `LATER_FEELING_SOURCES` names
1912
+ both: `row()`'s `feeling_peak_lived` leaves both out, and `sleep/consolidate.ts`'s
1913
+ recognition lane reads both only through the reflected-feeling door. Height and decay
1914
+ read every feeling, as before.
1915
+ - **`addFeelings`' `provenance` carries `createdAt`** (the dream's merge passes each
1916
+ original's): a feeling is a moment's, as a trait nudge's is, so a merge no longer dates
1917
+ what it carries to the merge night. `updated_at` is the write's. Rows merged before keep
1918
+ the date they were given.
1919
+
1920
+ ## 2026-10-03 — v12: the writer's three fields, and subject links (Release A of deliberate recall)
1921
+
1922
+ - **Three columns, not one, and none of them reused.** `happened_on` is the lived day of a
1923
+ write-up (`livedOn()` reads it for second-hand rows) and `event_date` is a future date to
1924
+ be reminded on; a write-up of yesterday that mentions something from August needs both,
1925
+ and a reminder needs its own. So `occurred_on` is new, with `event_date`'s shapes (day,
1926
+ month, range, year). `said_by` and `status` are new names because `source` (which
1927
+ channel wrote the row) and `kind` (physics kind) are taken. All NULL on every row the
1928
+ upgrade found: nothing can fill them without a model, and the store is keyless.
1929
+ - **Versions mirror them**, as they mirror `event_date`: they describe the words, and a
1930
+ revise that changes the words keeps the old three with the old words.
1931
+ - **`OBSERVER_READ_FLOOR` stays 11.** Each earlier raise answered yes to "does an
1932
+ instrument reading the older file get a wrong answer?". v12 re-files nothing; rows are
1933
+ read `m.*`, so a v11 row simply lacks the three; and the one reader of the new fields
1934
+ (doctor's `Write fields`) asks `hasColumn` first and is silent until the upgrade. Keeping
1935
+ the floor keeps doctor and the dashboard reading a v11 store between an install and the
1936
+ first writer. The row types carry the fields as `string | null`; on a v11 file they read
1937
+ undefined, so every reader takes them `?? null`.
1938
+ - **Links are written by the store, found by `schemas/`.** The store cannot import the
1939
+ alias index, and the alternative — linking in `Counterpart#creditNamedIn` — misses the
1940
+ doors that call `put` directly (a dream's gist and merge, a reflection's entry). So the
1941
+ composition root installs a finder (`findSubjectsWith`) and `insertOne` / `revise` link
1942
+ in the write's own transaction. Fail-open, with a `store.subjects.failed` event.
1943
+ - **The backfill runs after the open, not in the migration**, because the migrating
1944
+ transaction has no alias index. `Counterpart`'s constructor runs it once per store
1945
+ (writer-only, latched by `subjects.v12.backfill` in meta, read first), through
1946
+ `AliasIndex#scanner` — the same hits as `matchesIn` without trying every term on every
1947
+ text (a test holds the two equal). Cost on the live-sized store is one read of the
1948
+ memories' words and a token lookup per word.
1949
+ - **The upgrade records its moment** (`recall.v12.upgrade`): doctor counts the share of
1950
+ each field among memories written after it.
1951
+
1952
+ ## 2026-10-03 — `recallRows`, one read for facts mode
1953
+
1954
+ - Facts mode ranks in memory over every live row's columns (type, kind, title, dates, the
1955
+ writer's three fields, provenance, confidential, and `meta` for schemas and episodes only),
1956
+ read in one query rather than a `row()` per candidate. Never a body. A v11 file reads the
1957
+ three fields as null.
1958
+
1959
+ ## 2026-10-09 — a repeating reminder date, in meta (no schema bump)
1960
+
1961
+ - **`meta.recurring` (`RECURRING_META`), not a column.** The owner wanted recurring dates
1962
+ without a store-format change: a new version means a migration 0.3.12 cannot read back,
1963
+ and format changes are batched so migrations stay rare. The word sits beside
1964
+ `meta.remind`, its nearest sibling, and the anchor stays on `event_date` as stated. A
1965
+ build that never heard of it reads the anchor as a one-off date that has passed.
1966
+ - **`recurringMemories()`** is the read `datedMemories` cannot be: a birthday stated as
1967
+ `1990-05-14` never overlaps this year's span. Live rows (archived with
1968
+ `{ archived: true }`) with a DAY `event_date` and `meta LIKE '%"recurring":"%'`, the
1969
+ parsed meta deciding — the same loose-match-then-confirm `planCandidates` uses for
1970
+ `unresolved`. The partial `event_date` index bounds the scan to dated rows.
1971
+ `datedMemories` is unchanged.
@@ -62,9 +62,22 @@ export type FeelingWhose = (typeof FEELING_WHOSE)[number];
62
62
  * the time and is marked `recorded_later` with its date. The core's fast lane
63
63
  * reads only the first two unless `CORE_FAST_ACCEPTS_REFLECTED_FEELING` is set
64
64
  * (physics §5.3).
65
+ *
66
+ * `awake` (2026-10-02, lane B): the same feeling-now, recorded in an ordinary
67
+ * session when an old memory came up and felt different (`note`'s
68
+ * `feelingsNow`, `dream/reflect.ts#feelAgain`). No schema change — the column
69
+ * is TEXT. It is a LATER feeling exactly as a reflection's is: marked
70
+ * `recorded_later`, and read by the fast lane only through the same door
71
+ * (`LATER_FEELING_SOURCES`).
65
72
  */
66
- export const FEELING_SOURCES = ["session", "dream", "reflection"] as const;
73
+ export const FEELING_SOURCES = ["session", "dream", "reflection", "awake"] as const;
67
74
  export type FeelingSource = (typeof FEELING_SOURCES)[number];
75
+ /**
76
+ * The sources of a feeling recorded LATER, looking back — the ones the core's
77
+ * fast lane reads only when `CORE_FAST_ACCEPTS_REFLECTED_FEELING` is open
78
+ * (`store.row()`'s `feeling_peak_lived`, `sleep/consolidate.ts#selfRelevantFeeling`).
79
+ */
80
+ export const LATER_FEELING_SOURCES: readonly FeelingSource[] = ["reflection", "awake"];
68
81
 
69
82
  /**
70
83
  * `carried_by` is the nuance in the writer's own words — what in the moment