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
@@ -51,13 +51,29 @@
51
51
  * which did not fire inside the window is `blocked`, and the line says by
52
52
  * what. `REFUSAL_READERS` is still the only place a refusal column comes
53
53
  * from, and it still reads only fields a writer already fills.
54
+ * 5. **Not every mechanism has something to do every week** (2026-10-09).
55
+ * On the owner's store doctor went amber because two rows "went quiet":
56
+ * a plain reminder that had simply not fallen due, and the v8 upgrade's
57
+ * census, which runs once by design. A row with a `cadence` says so — a
58
+ * ONE-TIME job is `done` after it fires, an OCCASION-driven one is
59
+ * `waiting` while its occasion has not come — and where the store can
60
+ * tell whether the occasion came (`OCCASION_CHECKS`), an occasion that
61
+ * came and went unanswered is the finding, and stays one.
54
62
  */
55
63
  import { TUNABLES as ENCODE } from "../core/encode/tunables.js";
56
- import { addDays, daysBetween as calendarDaysBetween, localDate } from "../core/time.js";
64
+ import {
65
+ DATE_FROM_META,
66
+ DATE_LINEAGE_MAX,
67
+ PROSPECTIVE_PLAIN_EVENT,
68
+ cueModeOf,
69
+ windowKey,
70
+ } from "../core/prospective/index.js";
71
+ import { addDays, daysBetween as calendarDaysBetween, localDate, parseCalendarDate } from "../core/time.js";
57
72
  import type { EventRow, ReadOnlyStore } from "../core/store/index.js";
58
73
  import { rowToPhysics } from "../core/store/index.js";
59
74
  import { emotionalIntensity } from "../core/physics/index.js";
60
75
  import type { DurableEventName } from "./dashboard/registries.js";
76
+ import { NON_INTERACTIVE_ENTRYPOINTS, readSession } from "./sessions.js";
61
77
 
62
78
  /** The window every count on this page is measured over. Seven CALENDAR days,
63
79
  * inclusive of today — today and the six before it. */
@@ -95,6 +111,13 @@ export const PROBE_CEILING = 50_000;
95
111
  * has not yet been time for it to be a worry.
96
112
  * - `blind` — no durable evidence exists at all. The row says which row would
97
113
  * fix it. NOT a synonym for silent: a blind mechanism may be running fine.
114
+ * - `waiting` — it fires only on an occasion (an owner's action, a failure, a
115
+ * reminder falling due) and none came this week; or a one-time job whose
116
+ * occasion this store has never had. Not silence, and not a fault
117
+ * (2026-10-09). An occasion the store can SEE came and went unanswered is
118
+ * not `waiting`: that row keeps its `quiet` or `never` and is named in
119
+ * `missedOccasion`.
120
+ * - `done` — a one-time job (an upgrade's) that ran. Never `quiet`.
98
121
  * - `disabled` — stood down by a named decision (Amendment 15), not a fault.
99
122
  * - `retired` — a phase of the run ended and took the mechanism with it.
100
123
  */
@@ -105,6 +128,8 @@ export const FIRED_STATES = [
105
128
  "blind",
106
129
  "firing",
107
130
  "new",
131
+ "waiting",
132
+ "done",
108
133
  "disabled",
109
134
  "retired",
110
135
  ] as const;
@@ -119,6 +144,8 @@ export const STATE_ORDER: readonly FiredState[] = [
119
144
  "blind",
120
145
  "firing",
121
146
  "new",
147
+ "waiting",
148
+ "done",
122
149
  "disabled",
123
150
  "retired",
124
151
  ];
@@ -131,10 +158,40 @@ export const STATE_MEANING: Record<FiredState, string> = {
131
158
  never: "the evidence exists and has never carried a row",
132
159
  new: "never fired, and its evidence is younger than the window — not yet a worry",
133
160
  blind: "nothing durable records it, so firing and silence read alike",
161
+ waiting:
162
+ "it fires only when its occasion comes — an owner's action, a failure, a reminder falling due — so a week without one is not a fault",
163
+ done: "a one-time job: it ran once, as designed, and has nothing more to do",
134
164
  disabled: "stood down by a named decision, not a fault",
135
165
  retired: "a phase of the run ended and took it with it",
136
166
  };
137
167
 
168
+ /**
169
+ * HOW OFTEN A MECHANISM HAS A REASON TO FIRE, when it is not "whenever the
170
+ * store is used" (2026-10-09). Absent on most rows, and absent means what it
171
+ * always meant: a silence after a firing is `quiet`, the state worth reading
172
+ * first.
173
+ *
174
+ * - `one-time` — a job done once, at an upgrade. After it fires it is `done`,
175
+ * never `quiet`; before, `waiting`, because a store that never had the
176
+ * upgrade never had the job.
177
+ * - `occasion` — it fires only when its occasion arises: a plain reminder
178
+ * falling due, the owner erasing or exporting or un-merging, a failure. Its
179
+ * silence is `waiting`. `when` is the occasion in plain words, printed on
180
+ * the row. `check` names a reading of the store that says whether the
181
+ * occasion CAME this week (`OCCASION_CHECKS`); one that came and went
182
+ * unanswered is the one silence here that is still a fault.
183
+ *
184
+ * Classified only where the mechanism's own description makes it obvious; a
185
+ * row that is merely rare (promotion, the prune, the fade) is not an occasion,
186
+ * it is arithmetic that has not crossed its line yet, and keeps the old states.
187
+ */
188
+ export type Cadence =
189
+ | { readonly kind: "one-time"; readonly when: string }
190
+ | { readonly kind: "occasion"; readonly when: string; readonly check?: OccasionCheckId };
191
+
192
+ /** The occasions the store can see, each read by `OCCASION_CHECKS`. */
193
+ export type OccasionCheckId = "plain-due";
194
+
138
195
  /**
139
196
  * The table reads that stand in for a mechanism with no event of its own — the
140
197
  * five the inventory's §5(b) named, split where one table answers two questions.
@@ -264,6 +321,8 @@ export interface Mechanism {
264
321
  readonly disabled?: string;
265
322
  /** Retired with a phase of the run, with the phase named. */
266
323
  readonly retired?: string;
324
+ /** One-time or occasion-driven, when it is either (`Cadence`, 2026-10-09). */
325
+ readonly cadence?: Cadence;
267
326
  /**
268
327
  * Durable event names this row ACCOUNTS FOR in the coverage test, when they
269
328
  * are not simply its own evidence. A blind mechanism can still be the row that
@@ -429,6 +488,7 @@ export const MECHANISMS: readonly Mechanism[] = [
429
488
  id: "accommodation",
430
489
  label: "something the owner declared outright replaced what had been inferred",
431
490
  module: "schemas/",
491
+ cadence: { kind: "occasion", when: "the owner declares outright something that had only been inferred" },
432
492
  evidence: { kind: "probe", probe: "versions:replaced-by-declaration" },
433
493
  },
434
494
 
@@ -471,6 +531,21 @@ export const MECHANISMS: readonly Mechanism[] = [
471
531
  evidence: { kind: "event", names: ["mcp.recall"] },
472
532
  since: "2026-09-20",
473
533
  },
534
+ {
535
+ // Built 2026-10-02: every MCP result is measured against the one ceiling
536
+ // (`fit/TOOL_RESULT_CEILING`); one over it is cut there with a note,
537
+ // rather than saved by the host where the model cannot read it.
538
+ id: "result-cut",
539
+ label: "a tool answer too long for the host to show was cut to fit, with a note saying so, instead of vanishing into a file",
540
+ module: "mcp/server.ts (withinCeiling)",
541
+ cadence: { kind: "occasion", when: "a tool answer comes out too long for the host to show" },
542
+ evidence: { kind: "event", names: ["mcp.result.oversize"] },
543
+ // The same mechanism's failure, seen from the host's side (2026-10-09): a
544
+ // result under the ceiling that the host saved to a file anyway, read from
545
+ // the nightly run's own transcript (`claude-code/night-run.ts`).
546
+ covers: ["mcp.result.spilled"],
547
+ since: "2026-10-02",
548
+ },
474
549
  {
475
550
  id: "association",
476
551
  label: "two memories that came to mind together got wired to each other",
@@ -587,15 +662,19 @@ export const MECHANISMS: readonly Mechanism[] = [
587
662
  id: "core-demote",
588
663
  label: "the owner sent a core memory back to ordinary fading, and said why",
589
664
  module: "counterpart.ts#demoteCore",
665
+ cadence: { kind: "occasion", when: "the owner sends a core memory back" },
590
666
  evidence: { kind: "event", names: ["band.demoted"] },
591
667
  since: "2026-09-26",
592
668
  },
593
669
  {
594
670
  // The v8 upgrade's one-time proof: every memory measured by the old
595
671
  // arithmetic and the new. One row per store, ever; doctor reads the verdict.
672
+ // ONE-TIME (2026-10-09): it read `quiet` a week after it ran, and doctor
673
+ // went amber on a job that had finished — the false alarm `Cadence` ends.
596
674
  id: "upgrade-census",
597
675
  label: "after the v8 upgrade, every memory was checked by the old rules and the new",
598
676
  module: "sleep/upgrade.ts",
677
+ cadence: { kind: "one-time", when: "a store made before v8 is upgraded" },
599
678
  evidence: { kind: "event", names: ["physics.upgrade.census"] },
600
679
  since: "2026-09-26",
601
680
  },
@@ -608,9 +687,27 @@ export const MECHANISMS: readonly Mechanism[] = [
608
687
  // `no-similarity-supplied` is the embedder being off, which fires for EVERY
609
688
  // pair on the default configuration and already has its own amber on
610
689
  // doctor's Embedder line.
690
+ //
691
+ // AN OCCASION, AND AN EXACT ONE (2026-10-09). The owner's store, eighteen
692
+ // days and some eight hundred memories old, had never carried a row here,
693
+ // and the question was whether the wiring was broken. It is not: the night
694
+ // runs this phase on every cycle, but no similarity source is handed to it
695
+ // (`counterpart.ts` passes `runCycle` no `candidates`), so its only
696
+ // candidates are byte-identical bodies — and the door already refuses a
697
+ // repeat by content in the same directory (`DUPLICATE_CONTENT`,
698
+ // `remember/proposals.ts`). Reproduced on the seeded demo store: thirty
699
+ // cycles ran the phase, one merged the seed's planted copy, and a copy
700
+ // deposited from a second directory was merged that night. A DREAM's
701
+ // merge of near-copies is a different path with its own row
702
+ // (`dream.changed`, read by `dream-changes`); folding it in here would
703
+ // count one merge on two rows.
611
704
  id: "dedup",
612
- label: "a duplicate is merged into the memory it duplicates",
705
+ label: "an exact copy of a memory is merged into the one it copies, overnight",
613
706
  module: "sleep/dedup.ts",
707
+ cadence: {
708
+ kind: "occasion",
709
+ when: "an exact copy of a memory's words gets past the door, which turns a repeat away first (near-copies are a dream's to merge, on the dream's row)",
710
+ },
614
711
  evidence: { kind: "event", names: ["memory.merged"] },
615
712
  refusals: {
616
713
  names: ["sleep.cycle"],
@@ -620,10 +717,15 @@ export const MECHANISMS: readonly Mechanism[] = [
620
717
  },
621
718
  },
622
719
  {
623
- // TWO GATES out of five. `protected` is the owner saying this may never be
720
+ // THREE GATES out of six. `protected` is the owner saying this may never be
624
721
  // forgotten; `in-live-revision-chain` is a live chain holding a row that
625
- // the floor would otherwise have let go. Both are a rule refusing a memory
626
- // that qualified. `above-floor`, `dwell-too-short` and `band-not-episodic`
722
+ // the floor would otherwise have let go; `recurring` (2026-10-09) is a
723
+ // reminder date that still comes round, kept for its next occurrence —
724
+ // and physics names it only where the floor would otherwise have let the
725
+ // memory go (review of #341), or every pill reminder would read as a
726
+ // refusal every night. All three are a rule refusing a memory that
727
+ // qualified. `above-floor`,
728
+ // `dwell-too-short` and `band-not-episodic`
627
729
  // are the ordinary condition of almost every memory on almost every night —
628
730
  // the reviewer measured `dwell-too-short ×240` on a healthy forty-memory
629
731
  // store after seven boundaries.
@@ -634,7 +736,7 @@ export const MECHANISMS: readonly Mechanism[] = [
634
736
  refusals: {
635
737
  names: ["sleep.cycle"],
636
738
  under: "prune/blocked:",
637
- only: ["protected", "in-live-revision-chain"],
739
+ only: ["protected", "in-live-revision-chain", "recurring"],
638
740
  since: "2026-09-20",
639
741
  },
640
742
  },
@@ -667,6 +769,7 @@ export const MECHANISMS: readonly Mechanism[] = [
667
769
  id: "revision",
668
770
  label: "a belief took a credited challenge and was revised under the pressure",
669
771
  module: "schemas/index.ts",
772
+ cadence: { kind: "occasion", when: "a belief takes a credited challenge" },
670
773
  evidence: { kind: "event", names: ["revision.pressure"] },
671
774
  },
672
775
  {
@@ -677,8 +780,9 @@ export const MECHANISMS: readonly Mechanism[] = [
677
780
  id: "contradictions",
678
781
  label: "two memories that disagree were settled — changed, corrected or kept open — or flagged, or a settle undone",
679
782
  module: "core/contradictions.ts (revision.ts, dream/, mcp note, cli settle)",
783
+ cadence: { kind: "occasion", when: "two memories disagree" },
680
784
  evidence: { kind: "event", names: ["contradiction.settled"] },
681
- covers: ["contradiction.flagged", "contradiction.undone"],
785
+ covers: ["contradiction.flagged", "contradiction.undone", "contradiction.held"],
682
786
  since: "2026-09-29",
683
787
  },
684
788
  {
@@ -713,7 +817,9 @@ export const MECHANISMS: readonly Mechanism[] = [
713
817
  label: "the counterpart dreamed: replayed what was lived since the last dream, and wrote a journal",
714
818
  module: "dream/",
715
819
  evidence: { kind: "event", names: ["dream.journaled"] },
716
- covers: ["dream.begun", "dream.undone"],
820
+ // A bundle's later parts handed (2026-10-02), the dream's and the
821
+ // reflection's both: the reading the journal was written from.
822
+ covers: ["dream.begun", "dream.undone", "mcp.part"],
717
823
  since: "2026-09-26",
718
824
  },
719
825
  {
@@ -805,8 +911,9 @@ export const MECHANISMS: readonly Mechanism[] = [
805
911
  module: "handoff/index.ts",
806
912
  evidence: { kind: "event", names: ["handoff.shown"] },
807
913
  // A "Last here" line dropped for room (durable since 2026-10-01) rides with
808
- // the delivery it was turned away from, as `no-room` rides with writing.
809
- covers: ["handoff.lasthere.noroom"],
914
+ // the delivery it was turned away from, as `no-room` rides with writing;
915
+ // so does a "Work here" overflow (2026-10-02).
916
+ covers: ["handoff.lasthere.noroom", "self.work.overflow"],
810
917
  since: "2026-09-20",
811
918
  },
812
919
  {
@@ -814,10 +921,14 @@ export const MECHANISMS: readonly Mechanism[] = [
814
921
  label: "that briefing was handed to the host at the start of a session",
815
922
  module: "claude-code/hooks.ts",
816
923
  evidence: { kind: "event", names: ["adapter.wake.injected"] },
924
+ // What the envelope could not carry rides with the handing-over (durable
925
+ // since 2026-10-02): past the host's cap, a notice dropped, a part that
926
+ // waited for room, a start over the ceiling the host reported.
927
+ covers: ["adapter.envelope.overcap", "adapter.notice.dropped", "adapter.envelope.gave-way", "adapter.injection.overbudget"],
817
928
  },
818
929
  {
819
930
  id: "wake-delivered",
820
- label: "whether the briefing actually arrived was checked on the next turn",
931
+ label: "whether the briefing actually arrived was checked at the first prompt or the first Stop",
821
932
  module: "claude-code/hooks.ts",
822
933
  evidence: { kind: "event", names: ["adapter.wake.delivered"] },
823
934
  },
@@ -832,6 +943,7 @@ export const MECHANISMS: readonly Mechanism[] = [
832
943
  id: "protection",
833
944
  label: "the owner marked a memory permanent, so nothing may revise or forget it",
834
945
  module: "physics/, store/",
946
+ cadence: { kind: "occasion", when: "the owner marks a memory permanent" },
835
947
  evidence: {
836
948
  kind: "probe",
837
949
  probe: "protected",
@@ -843,12 +955,14 @@ export const MECHANISMS: readonly Mechanism[] = [
843
955
  id: "removal",
844
956
  label: "the owner erased a memory, and the erasure left a record",
845
957
  module: "store/owner-op-seam.ts",
958
+ cadence: { kind: "occasion", when: "the owner erases a memory" },
846
959
  evidence: { kind: "probe", probe: "removals" },
847
960
  },
848
961
  {
849
962
  id: "unmerge",
850
963
  label: "the owner put back a memory a merge had archived",
851
964
  module: "store/owner-op-seam.ts",
965
+ cadence: { kind: "occasion", when: "the owner puts back a memory a merge archived" },
852
966
  evidence: { kind: "event", names: ["memory.unmerged"] },
853
967
  },
854
968
  {
@@ -879,6 +993,7 @@ export const MECHANISMS: readonly Mechanism[] = [
879
993
  id: "prospective-fired",
880
994
  label: "that future date arrived and the reminder came back",
881
995
  module: "prospective/, counterpart.ts#spendArrivals",
996
+ cadence: { kind: "occasion", when: "a dated memory's day comes round and it comes up in a turn" },
882
997
  evidence: { kind: "event", names: ["prospective.fire"] },
883
998
  // The refusal row is ACCOUNTED FOR here, and deliberately not read as a
884
999
  // refusal column: its reasons are budget and calendar ("already fired
@@ -890,9 +1005,16 @@ export const MECHANISMS: readonly Mechanism[] = [
890
1005
  {
891
1006
  // A PLAIN reminder told to the person on its day (2026-09-26): one row per
892
1007
  // memory, window and beat, latched.
1008
+ //
1009
+ // AN OCCASION THE STORE CAN SEE (2026-10-09). A week with no plain reminder
1010
+ // due is `waiting` — on the owner's store it went `quiet` six days after
1011
+ // its last one and turned doctor amber. A week where one fell due on a day
1012
+ // a session ran, and was not said, is the fault this row exists for, and
1013
+ // `OCCASION_CHECKS["plain-due"]` keeps it amber.
893
1014
  id: "prospective-plain",
894
1015
  label: "a reminder marked plain was said plainly on its day",
895
1016
  module: "prospective/, lifecycle.ts",
1017
+ cadence: { kind: "occasion", when: "a reminder marked plain falls due on a day a session runs", check: "plain-due" },
896
1018
  evidence: { kind: "event", names: ["prospective.plain"] },
897
1019
  since: "2026-09-26",
898
1020
  },
@@ -932,6 +1054,7 @@ export const MECHANISMS: readonly Mechanism[] = [
932
1054
  id: "worker-trouble",
933
1055
  label: "the worker was refused, could not be started, or failed after starting",
934
1056
  module: "lifecycle.ts, bin/runner.ts",
1057
+ cadence: { kind: "occasion", when: "the worker is refused, cannot start, or fails" },
935
1058
  evidence: {
936
1059
  kind: "event",
937
1060
  names: ["adapter.spawn.refused", "adapter.spawn.failed", "adapter.runner.failed"],
@@ -974,6 +1097,7 @@ export const MECHANISMS: readonly Mechanism[] = [
974
1097
  id: "snapshot-trouble",
975
1098
  label: "a copy of the store could not be made (the store itself is unharmed)",
976
1099
  module: "adapters/snapshots.ts",
1100
+ cadence: { kind: "occasion", when: "a copy of the store fails" },
977
1101
  evidence: { kind: "event", names: ["snapshot.failed"] },
978
1102
  since: "2026-09-18",
979
1103
  },
@@ -1031,6 +1155,7 @@ export const MECHANISMS: readonly Mechanism[] = [
1031
1155
  id: "export",
1032
1156
  label: "the owner took a readable copy of the memories off this machine, by hand",
1033
1157
  module: "cli/export.ts",
1158
+ cadence: { kind: "occasion", when: "the owner exports" },
1034
1159
  evidence: { kind: "event", names: ["store.export"] },
1035
1160
  since: "2026-09-20",
1036
1161
  },
@@ -1056,8 +1181,17 @@ export interface FiredRow {
1056
1181
  readonly topRefusal: string | null;
1057
1182
  /** The dotted names or the table this row was read from, for the reader who greps. */
1058
1183
  readonly evidence: string;
1059
- /** Present on `blind`, `disabled`, `retired` and `new` — the line that says why. */
1184
+ /** Present on `blind`, `disabled`, `retired`, `new`, `waiting`, `done` and a
1185
+ * missed occasion — the line that says why. */
1060
1186
  readonly note: string | null;
1187
+ /** `one-time` or `occasion` when the registry says so (`Cadence`), else null. */
1188
+ readonly cadence: Cadence["kind"] | null;
1189
+ /**
1190
+ * Occasions the store SAW this week that this mechanism did not answer — a
1191
+ * plain reminder due on a day a session ran, not said. 0 when nothing was
1192
+ * missed, and 0 on every row without an occasion check.
1193
+ */
1194
+ readonly occasionMissed: number;
1061
1195
  }
1062
1196
 
1063
1197
  export interface FiredReport {
@@ -1093,6 +1227,14 @@ export interface FiredReport {
1093
1227
  * finding read greener.
1094
1228
  */
1095
1229
  readonly wentBlocked: readonly string[];
1230
+ /**
1231
+ * Occasion-driven mechanisms whose occasion the store SAW come this week and
1232
+ * that did not answer it, by label with what was missed (2026-10-09). The
1233
+ * third list doctor grades on: `waiting` takes an occasion row out of
1234
+ * `wentQuiet`, and without this list a plain reminder due and not said —
1235
+ * this week, with nothing last week to compare — would have read green.
1236
+ */
1237
+ readonly missedOccasion: readonly string[];
1096
1238
  /** The store's own clock — the number of days it has actually LIVED. */
1097
1239
  readonly livedDay: number;
1098
1240
  /** Calendar days between the oldest row this pass read and today, or null
@@ -1181,12 +1323,19 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
1181
1323
 
1182
1324
  const rows: FiredRow[] = [];
1183
1325
  const notRead: string[] = [];
1326
+ const missedOccasion: string[] = [];
1184
1327
  for (const m of MECHANISMS) {
1185
1328
  if (m.evidence.kind === "probe" && probed === null) {
1186
1329
  notRead.push(m.id);
1187
1330
  continue;
1188
1331
  }
1189
- rows.push(rowFor(m, log, probed, window));
1332
+ // An occasion check reads memories, so it costs what a probe costs and is
1333
+ // skipped with them: an unchecked occasion row reads `waiting`, claiming
1334
+ // nothing either way.
1335
+ const occasion = probed === null ? null : readOccasion(m, store, log, window);
1336
+ const row = rowFor(m, log, probed, window, occasion);
1337
+ rows.push(row);
1338
+ if (occasion !== null && occasion.missed > 0) missedOccasion.push(`${row.label} (${occasion.says})`);
1190
1339
  }
1191
1340
 
1192
1341
  const counts = Object.fromEntries(FIRED_STATES.map((s) => [s, 0])) as Record<FiredState, number>;
@@ -1223,8 +1372,11 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
1223
1372
  !comparisonIsTooYoung(r.id, window),
1224
1373
  )
1225
1374
  .map((r) => `${r.label} (${r.topRefusal ?? UNNAMED_REFUSAL})`),
1375
+ // A missed occasion is named in its own list, with what was missed, rather
1376
+ // than twice.
1377
+ missedOccasion,
1226
1378
  wentQuiet: rows
1227
- .filter((r) => r.state === "quiet" && r.firedInPreviousWindow > 0)
1379
+ .filter((r) => r.state === "quiet" && r.firedInPreviousWindow > 0 && r.occasionMissed === 0)
1228
1380
  // A row whose table keeps only LIVED days was compared on the lived clock,
1229
1381
  // which has run seven days across fifteen calendar ones — so the sentence
1230
1382
  // says which clock answered rather than claiming a calendar week it did
@@ -1295,9 +1447,15 @@ const EMPTY_READING: Reading = {
1295
1447
  blind: null,
1296
1448
  };
1297
1449
 
1298
- function rowFor(m: Mechanism, log: LogRead, probed: Probed | null, w: Window): FiredRow {
1450
+ function rowFor(
1451
+ m: Mechanism,
1452
+ log: LogRead,
1453
+ probed: Probed | null,
1454
+ w: Window,
1455
+ occasion: OccasionReading | null = null,
1456
+ ): FiredRow {
1299
1457
  const read = readEvidence(m, log, probed);
1300
- const state = stateOf(m, read, w);
1458
+ const state = stateOf(m, read, w, occasion);
1301
1459
  return {
1302
1460
  id: m.id,
1303
1461
  label: m.label,
@@ -1311,7 +1469,9 @@ function rowFor(m: Mechanism, log: LogRead, probed: Probed | null, w: Window): F
1311
1469
  refusedInWindow: read.refused,
1312
1470
  topRefusal: read.topRefusal,
1313
1471
  evidence: read.evidence,
1314
- note: noteFor(m, read, state),
1472
+ note: noteFor(m, read, state, occasion),
1473
+ cadence: m.cadence?.kind ?? null,
1474
+ occasionMissed: occasion?.missed ?? 0,
1315
1475
  };
1316
1476
  }
1317
1477
 
@@ -1321,7 +1481,7 @@ function rowFor(m: Mechanism, log: LogRead, probed: Probed | null, w: Window): F
1321
1481
  * count; blindness is a fact about the EVIDENCE and outranks the rest; only then
1322
1482
  * do the counts speak.
1323
1483
  */
1324
- function stateOf(m: Mechanism, read: Reading, w: Window): FiredState {
1484
+ function stateOf(m: Mechanism, read: Reading, w: Window, occasion: OccasionReading | null = null): FiredState {
1325
1485
  if (m.disabled !== undefined) return "disabled";
1326
1486
  if (m.retired !== undefined) return "retired";
1327
1487
  if (read.blind !== null) return "blind";
@@ -1330,7 +1490,17 @@ function stateOf(m: Mechanism, read: Reading, w: Window): FiredState {
1330
1490
  // `never` because it answers the question they leave open: a mechanism that
1331
1491
  // was turned away every time it was reached is not one that had nothing to do.
1332
1492
  if (read.refused > 0) return "blocked";
1493
+ // A JOB DONE ONCE IS DONE (2026-10-09), not quiet: the census that ran at
1494
+ // the v8 upgrade has nothing to do the week after, or ever again.
1495
+ if (m.cadence?.kind === "one-time" && read.total > 0) return "done";
1496
+ // AN OCCASION NOT COME IS NOT A SILENCE (2026-10-09) — unless the store saw
1497
+ // it come and go unanswered, and then the row keeps `quiet` or `never`
1498
+ // below, because that silence is exactly the finding.
1499
+ if (m.cadence !== undefined && (occasion === null || occasion.missed === 0)) return "waiting";
1333
1500
  if (read.total > 0) return "quiet";
1501
+ // ...and a missed occasion is a worry however young its evidence: `new`
1502
+ // means "not yet had the chance", and this one had it.
1503
+ if (occasion !== null && occasion.missed > 0) return "never";
1334
1504
  // Never fired. A mechanism whose EVIDENCE is younger than the window has not
1335
1505
  // had time to be a worry yet, and grading it as one is how a view teaches its
1336
1506
  // reader to ignore it.
@@ -1338,10 +1508,29 @@ function stateOf(m: Mechanism, read: Reading, w: Window): FiredState {
1338
1508
  return "never";
1339
1509
  }
1340
1510
 
1341
- function noteFor(m: Mechanism, read: Reading, state: FiredState): string | null {
1511
+ function noteFor(
1512
+ m: Mechanism,
1513
+ read: Reading,
1514
+ state: FiredState,
1515
+ occasion: OccasionReading | null = null,
1516
+ ): string | null {
1342
1517
  if (state === "disabled") return m.disabled ?? null;
1343
1518
  if (state === "retired") return m.retired ?? null;
1344
1519
  if (state === "blind") return read.blind;
1520
+ // What was missed is said whatever else the row says: a week that told one
1521
+ // plain reminder and dropped another is `firing`, and still owes a sentence.
1522
+ if (occasion !== null && occasion.missed > 0) {
1523
+ return `its occasion came this week and was not answered: ${occasion.says}`;
1524
+ }
1525
+ if (state === "done" && m.cadence !== undefined) {
1526
+ return `a one-time job, run when ${m.cadence.when}; it has run, and has nothing more to do`;
1527
+ }
1528
+ if (state === "waiting" && m.cadence !== undefined) {
1529
+ if (m.cadence.kind === "one-time") {
1530
+ return `a one-time job, run when ${m.cadence.when}; this store has not needed it`;
1531
+ }
1532
+ return `it fires only when ${m.cadence.when}${occasion === null ? "" : `; ${occasion.says}`}`;
1533
+ }
1345
1534
  if (state === "new" && m.since !== undefined) return `its evidence was added ${m.since}`;
1346
1535
  if (state === "blocked") {
1347
1536
  // The whole point of the state, in one sentence: not "quiet", not "never" —
@@ -1467,8 +1656,38 @@ interface LogRead {
1467
1656
  /** The calendar date of the OLDEST row this pass saw, for the store's age.
1468
1657
  * A truncated read is the oldest rows, so this stays right when it happens. */
1469
1658
  readonly oldestDate: string | null;
1659
+ /**
1660
+ * The rows of THIS window that say a session was there (2026-10-09): a
1661
+ * session start handed its briefing, or a turn decided what came to mind —
1662
+ * the two moments a plain reminder is said (`claude-code/hooks.ts`).
1663
+ * `presentDays` keeps the ones a person could have been told something in;
1664
+ * an occasion check reads that, because a reminder due on a day nobody came
1665
+ * is not one a session could have said.
1666
+ */
1667
+ readonly presence: readonly PresenceRow[];
1668
+ /**
1669
+ * What each session's briefing row said about whether anybody could be told
1670
+ * anything in it (`interactive` on `adapter.wake.injected`, review of #337),
1671
+ * by session id, from every briefing this pass read. Absent: the row did not
1672
+ * say, or this pass did not see it.
1673
+ */
1674
+ readonly attended: ReadonlyMap<string, boolean>;
1675
+ }
1676
+
1677
+ /** One row of the window that says a session was there (`PRESENCE_EVENTS`). */
1678
+ interface PresenceRow {
1679
+ readonly date: string;
1680
+ readonly at: number;
1681
+ /** The session it belongs to, or null when the row names none. */
1682
+ readonly session: string | null;
1470
1683
  }
1471
1684
 
1685
+ /** The briefing row: the one that says whether its session is attended. */
1686
+ const WAKE_EVENT = "adapter.wake.injected";
1687
+
1688
+ /** The rows that say a session was there: a briefing handed over, a turn decided. */
1689
+ const PRESENCE_EVENTS: ReadonlySet<string> = new Set([WAKE_EVENT, "recall.decision"]);
1690
+
1472
1691
  /**
1473
1692
  * The tally key for a name read through a `positive` filter. A character no
1474
1693
  * durable event name carries, so it cannot collide with a real one.
@@ -1518,11 +1737,11 @@ function emptyTally(): NameTally {
1518
1737
  */
1519
1738
  function readLog(store: ReadOnlyStore, w: Window): LogRead {
1520
1739
  const byName = new Map<string, NameTally>();
1521
- const age = { oldest: null as string | null };
1740
+ const age: PassState = { oldest: null, presence: [], attended: new Map() };
1522
1741
  const first = store.eventLog({ limit: EVENT_CEILING });
1523
1742
  for (const row of first) tallyRow(byName, row, w, age);
1524
1743
  if (first.length < EVENT_CEILING) {
1525
- return { byName, truncated: false, oldestDate: age.oldest };
1744
+ return { byName, truncated: false, oldestDate: age.oldest, presence: age.presence, attended: age.attended };
1526
1745
  }
1527
1746
  const lastSeq = first[first.length - 1]?.seq ?? 0;
1528
1747
  // A lived day is never longer than a calendar day, so `livedDay - 14` cannot
@@ -1535,18 +1754,30 @@ function readLog(store: ReadOnlyStore, w: Window): LogRead {
1535
1754
  if (row.seq <= lastSeq) continue;
1536
1755
  tallyRow(byName, row, w, age);
1537
1756
  }
1538
- return { byName, truncated: true, oldestDate: age.oldest };
1757
+ return { byName, truncated: true, oldestDate: age.oldest, presence: age.presence, attended: age.attended };
1539
1758
  }
1540
1759
 
1541
- function tallyRow(
1542
- byName: Map<string, NameTally>,
1543
- row: EventRow,
1544
- w: Window,
1545
- age: { oldest: string | null },
1546
- ): void {
1760
+ /** What one pass over the log gathers beside the tallies. */
1761
+ interface PassState {
1762
+ oldest: string | null;
1763
+ presence: PresenceRow[];
1764
+ attended: Map<string, boolean>;
1765
+ }
1766
+
1767
+ function tallyRow(byName: Map<string, NameTally>, row: EventRow, w: Window, age: PassState): void {
1547
1768
  const payload = payloadOf(row);
1548
1769
  const date = rowDate(row, payload, w.zone);
1549
1770
  if (age.oldest === null || date < age.oldest) age.oldest = date;
1771
+ if (PRESENCE_EVENTS.has(row.name)) {
1772
+ const session = str(payload, "session") ?? (row.ref !== null && row.ref.length > 0 ? row.ref : null);
1773
+ const said = payload["interactive"];
1774
+ // Any briefing that says nobody attends marks the session; a later one
1775
+ // saying otherwise does not unmark it (a compaction re-fires the start).
1776
+ if (row.name === WAKE_EVENT && session !== null && typeof said === "boolean" && age.attended.get(session) !== false) {
1777
+ age.attended.set(session, said);
1778
+ }
1779
+ if (date >= w.from && date <= w.to) age.presence.push({ date, at: row.at, session });
1780
+ }
1550
1781
  const t = countInto(byName, row.name, date, w);
1551
1782
  // THE FILTERED TALLIES, in the same pass (`Evidence.positive`). They count
1552
1783
  // the row and NOTHING ELSE: the refusal reader below answers for every phase
@@ -1731,6 +1962,177 @@ function str(p: Record<string, unknown>, key: string): string | null {
1731
1962
  return typeof v === "string" && v.length > 0 ? v : null;
1732
1963
  }
1733
1964
 
1965
+ // ── occasions the store can see ─────────────────────────────────────────────
1966
+
1967
+ /**
1968
+ * WHETHER AN OCCASION CAME, AND WHETHER IT WAS ANSWERED (2026-10-09).
1969
+ *
1970
+ * An occasion-driven row is `waiting` while its occasion has not come, which
1971
+ * takes it out of `wentQuiet` — so where the store CAN tell that the occasion
1972
+ * came this week, it has to say so here, or a real fault would read green.
1973
+ */
1974
+ export interface OccasionReading {
1975
+ /** Occasions this week that went unanswered. Above 0, the row is a finding. */
1976
+ readonly missed: number;
1977
+ /** One plain sentence: what came, or that nothing did. */
1978
+ readonly says: string;
1979
+ }
1980
+
1981
+ /** The checks, by `OccasionCheckId`. Each is a READ, and each may fail. */
1982
+ const OCCASION_CHECKS: Record<
1983
+ OccasionCheckId,
1984
+ (store: ReadOnlyStore, log: LogRead, w: Window) => OccasionReading
1985
+ > = {
1986
+ "plain-due": plainDueReading,
1987
+ };
1988
+
1989
+ /** The occasion reading for one mechanism, or null when it has no check — or
1990
+ * when its check could not be read, which is "cannot tell", never a fault. */
1991
+ function readOccasion(m: Mechanism, store: ReadOnlyStore, log: LogRead, w: Window): OccasionReading | null {
1992
+ if (m.cadence?.kind !== "occasion" || m.cadence.check === undefined) return null;
1993
+ try {
1994
+ return OCCASION_CHECKS[m.cadence.check](store, log, w);
1995
+ } catch {
1996
+ return null;
1997
+ }
1998
+ }
1999
+
2000
+ /**
2001
+ * WAS A PLAIN REMINDER DUE THIS WEEK, AND WAS IT SAID?
2002
+ *
2003
+ * The beats are `Prospective#plainDue`'s, restated as a read because that
2004
+ * method refuses an observer and doctor is one: a DAY item is due on its day;
2005
+ * a MONTH or RANGE item opens (`opens`) on the first day it is seen inside its
2006
+ * span and is due again on its last day (`last-day`); a YEAR is never told.
2007
+ * A beat is told when its latch row exists (`prospective.plain`, keyed
2008
+ * `<memory>:<window>:<beat>`) on the memory or on any memory its reminder
2009
+ * moved from — the same lineage `plainTold` walks.
2010
+ *
2011
+ * A beat counts as DUE only on a day of the window, today excluded, on which a
2012
+ * session a person could be told something in was there AFTER the memory
2013
+ * existed (`presentDays`): a reminder is said at a session start or a turn, so
2014
+ * a day nobody came, a day only the headless run or `claude -p` came, or a
2015
+ * reminder written at the day's last turn, is not one a session could have
2016
+ * said. Today is left out because its sessions may still say it.
2017
+ *
2018
+ * A memory that cannot be read is skipped, as `plainDue` skips it, rather than
2019
+ * failing the whole reading: one unreadable row must not turn a real miss on
2020
+ * another into "cannot tell" (review of #337).
2021
+ */
2022
+ function plainDueReading(store: ReadOnlyStore, log: LogRead, w: Window): OccasionReading {
2023
+ const lastDay = daysBefore(w.to, 1);
2024
+ const none: OccasionReading = { missed: 0, says: "none fell due this week on a day a session ran" };
2025
+ if (lastDay < w.from) return none;
2026
+ const denied = new Set(store.deniedIds());
2027
+ // Read only once a plain reminder is in the window: most weeks there is none.
2028
+ let present: ReadonlyMap<string, number> | null = null;
2029
+ let due = 0;
2030
+ let missed = 0;
2031
+ for (const dated of store.datedMemories(w.from, lastDay)) {
2032
+ if (denied.has(dated.id)) continue;
2033
+ const row = store.row(dated.id);
2034
+ if (row === undefined || row.archived === 1 || row.superseded_by !== null) continue;
2035
+ let doc;
2036
+ try {
2037
+ doc = store.read(dated.id).doc;
2038
+ } catch {
2039
+ continue;
2040
+ }
2041
+ if (doc.type === "episode" || cueModeOf(doc) !== "plain") continue;
2042
+ const span = parseCalendarDate(dated.eventDate);
2043
+ if (span === null || span.text !== dated.eventDate || span.precision === "year") continue;
2044
+ present ??= presentDays(store, log);
2045
+ const beats = new Set<string>();
2046
+ for (let day = span.first > w.from ? span.first : w.from; day <= lastDay && day <= span.last; day = addDays(day, 1)) {
2047
+ const seen = present.get(day);
2048
+ // An older row with no birth moment is read as existing all along.
2049
+ if (seen === undefined || seen <= (row.created_at ?? 0)) continue;
2050
+ beats.add(span.precision === "day" ? "day" : day === span.last ? "last-day" : "opens");
2051
+ }
2052
+ if (beats.size === 0) continue;
2053
+ due += 1;
2054
+ const key = windowKey(dated.eventDate, span.precision);
2055
+ const lineage = plainLineage(store, dated.id);
2056
+ // Counted per REMINDER, not per beat: a month item that missed both its
2057
+ // opening and its last day is one reminder not said.
2058
+ const untold = [...beats].some(
2059
+ (beat) =>
2060
+ !lineage.some((id) =>
2061
+ store
2062
+ .eventLog({ name: PROSPECTIVE_PLAIN_EVENT, ref: id, order: "desc", limit: 50 })
2063
+ .some((e) => e.dedup_key === `${PROSPECTIVE_PLAIN_EVENT}:${id}:${key}:${beat}`),
2064
+ ),
2065
+ );
2066
+ if (untold) missed += 1;
2067
+ }
2068
+ if (due === 0) return none;
2069
+ if (missed === 0) {
2070
+ return { missed: 0, says: `${String(due)} fell due this week, and ${due === 1 ? "it was" : "each was"} said` };
2071
+ }
2072
+ return {
2073
+ missed,
2074
+ says: `${String(missed)} plain ${missed === 1 ? "reminder was" : "reminders were"} due on a day a session ran and not said`,
2075
+ };
2076
+ }
2077
+
2078
+ /**
2079
+ * THE DAYS A PERSON COULD HAVE BEEN TOLD SOMETHING, each with its newest such
2080
+ * moment (review of #337). A session nobody attends — the headless nightly
2081
+ * run, `claude -p`, an Agent SDK one — still writes a briefing row and turns,
2082
+ * but is never handed a plain reminder (`hooks.ts#isInteractive`,
2083
+ * `SessionInput.nightRun`), so its rows are not an occasion: counted, every
2084
+ * day the night run came read as a day a reminder went unsaid.
2085
+ *
2086
+ * Its briefing row says so (`interactive`). A row written before that field,
2087
+ * or a session whose briefing this pass did not see, is asked of the session's
2088
+ * registry record — its `entrypoint`, as `sessions.ts#pointable` asks — and a
2089
+ * session nothing is known about reads as a person's, the direction that keeps
2090
+ * the finding rather than hiding it.
2091
+ */
2092
+ function presentDays(store: ReadOnlyStore, log: LogRead): Map<string, number> {
2093
+ const asked = new Map<string, boolean>();
2094
+ const unattended = (session: string | null): boolean => {
2095
+ if (session === null) return false;
2096
+ const said = log.attended.get(session);
2097
+ if (said !== undefined) return !said;
2098
+ let known = asked.get(session);
2099
+ if (known === undefined) {
2100
+ const entrypoint = readSession(store.dir, session)?.entrypoint;
2101
+ known = entrypoint !== undefined && NON_INTERACTIVE_ENTRYPOINTS.has(entrypoint);
2102
+ asked.set(session, known);
2103
+ }
2104
+ return known;
2105
+ };
2106
+ const out = new Map<string, number>();
2107
+ for (const p of log.presence) {
2108
+ if (unattended(p.session)) continue;
2109
+ const was = out.get(p.date);
2110
+ if (was === undefined || p.at > was) out.set(p.date, p.at);
2111
+ }
2112
+ return out;
2113
+ }
2114
+
2115
+ /** The memory, then each one its reminder moved from — `Prospective`'s private
2116
+ * walk, read the same way: `meta.reminderFrom`, bounded, cycle-safe. */
2117
+ function plainLineage(store: ReadOnlyStore, memoryId: string): string[] {
2118
+ const out = [memoryId];
2119
+ let current = memoryId;
2120
+ for (let hop = 0; hop < DATE_LINEAGE_MAX; hop++) {
2121
+ const raw = store.row(current)?.meta;
2122
+ if (raw === undefined || raw === null) break;
2123
+ let from: unknown;
2124
+ try {
2125
+ from = (JSON.parse(raw) as Record<string, unknown>)[DATE_FROM_META];
2126
+ } catch {
2127
+ break;
2128
+ }
2129
+ if (typeof from !== "string" || out.includes(from)) break;
2130
+ out.push(from);
2131
+ current = from;
2132
+ }
2133
+ return out;
2134
+ }
2135
+
1734
2136
  // ── the table probes ────────────────────────────────────────────────────────
1735
2137
 
1736
2138
  interface ProbeTally {