counterparts 0.3.12 → 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 (116) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/docs/module-map.md +1 -1
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +36 -10
  5. package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
  6. package/src/adapters/claude-code/NOTES.md +131 -0
  7. package/src/adapters/claude-code/bin/hook.ts +35 -2
  8. package/src/adapters/claude-code/doctor.ts +155 -21
  9. package/src/adapters/claude-code/hooks.ts +49 -7
  10. package/src/adapters/claude-code/index.ts +11 -0
  11. package/src/adapters/claude-code/night-run.ts +133 -12
  12. package/src/adapters/claude-code/transcript.ts +268 -1
  13. package/src/adapters/cli/CONTRACT.md +5 -0
  14. package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
  15. package/src/adapters/cli/NOTES.md +111 -0
  16. package/src/adapters/cli/commands.ts +65 -14
  17. package/src/adapters/cli/dream-core.ts +57 -42
  18. package/src/adapters/cli/export.ts +320 -21
  19. package/src/adapters/cli/index.ts +1 -0
  20. package/src/adapters/cli/install.ts +39 -7
  21. package/src/adapters/cli/mechanisms.ts +7 -1
  22. package/src/adapters/cli/uninstall.ts +13 -5
  23. package/src/adapters/cli/wire.ts +189 -63
  24. package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
  25. package/src/adapters/dashboard/NOTES.md +79 -0
  26. package/src/adapters/dashboard/registries.ts +10 -2
  27. package/src/adapters/dashboard/web/README.md +19 -14
  28. package/src/adapters/dashboard/web/actions.ts +23 -1
  29. package/src/adapters/dashboard/web/flow.ts +4 -1
  30. package/src/adapters/dashboard/web/lanes.ts +3 -0
  31. package/src/adapters/dashboard/web/narrate.ts +30 -2
  32. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
  33. package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
  34. package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
  35. package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
  36. package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
  37. package/src/adapters/dashboard/web/server.ts +0 -5
  38. package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
  39. package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
  40. package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
  41. package/src/adapters/dashboard/web/views/health.ts +1 -1
  42. package/src/adapters/dashboard/web/views/search.ts +4 -45
  43. package/src/adapters/dashboard/web/views.ts +2 -2
  44. package/src/adapters/fired.ts +410 -25
  45. package/src/adapters/host-wiring.ts +300 -0
  46. package/src/adapters/lifecycle.ts +14 -0
  47. package/src/adapters/log/index.ts +2 -0
  48. package/src/adapters/mcp/CONTRACT.md +33 -3
  49. package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
  50. package/src/adapters/mcp/NOTES.md +136 -0
  51. package/src/adapters/mcp/bin/serve.ts +30 -0
  52. package/src/adapters/mcp/facts.ts +13 -1
  53. package/src/adapters/mcp/meaning.ts +208 -13
  54. package/src/adapters/mcp/server.ts +87 -15
  55. package/src/adapters/mcp/stdio.ts +3 -1
  56. package/src/adapters/mcp/stood-down.ts +51 -0
  57. package/src/adapters/mcp/tools.ts +27 -7
  58. package/src/adapters/plugin-run.sh +133 -0
  59. package/src/adapters/plugin.ts +329 -0
  60. package/src/core/associate/CONTRACT.md +2 -1
  61. package/src/core/associate/INTERFACE-GAPS.md +6 -1
  62. package/src/core/associate/NOTES.md +45 -0
  63. package/src/core/briefing.ts +12 -3
  64. package/src/core/contradictions.ts +184 -0
  65. package/src/core/counterpart.ts +451 -18
  66. package/src/core/dream/CONTRACT.md +5 -2
  67. package/src/core/dream/INTERFACE-GAPS.md +29 -6
  68. package/src/core/dream/NOTES.md +21 -0
  69. package/src/core/dream/index.ts +33 -1
  70. package/src/core/dream/reflect.ts +20 -5
  71. package/src/core/encode/INTERFACE-GAPS.md +3 -1
  72. package/src/core/fit/INTERFACE-GAPS.md +8 -2
  73. package/src/core/fit/NOTES.md +5 -2
  74. package/src/core/fit/index.ts +4 -1
  75. package/src/core/handoff/CONTRACT.md +37 -2
  76. package/src/core/handoff/INTERFACE-GAPS.md +10 -0
  77. package/src/core/handoff/NOTES.md +66 -0
  78. package/src/core/handoff/index.ts +214 -12
  79. package/src/core/mint.ts +8 -2
  80. package/src/core/physics/CONTRACT.md +11 -1
  81. package/src/core/physics/NOTES.md +30 -0
  82. package/src/core/physics/index.ts +26 -4
  83. package/src/core/prospective/CONTRACT.md +45 -6
  84. package/src/core/prospective/INTERFACE-GAPS.md +4 -0
  85. package/src/core/prospective/NOTES.md +138 -0
  86. package/src/core/prospective/derive.ts +33 -5
  87. package/src/core/prospective/index.ts +90 -5
  88. package/src/core/prospective/windows.ts +72 -1
  89. package/src/core/recall/CONTRACT.md +6 -2
  90. package/src/core/recall/INTERFACE-GAPS.md +28 -4
  91. package/src/core/recall/NOTES.md +57 -1
  92. package/src/core/recall/probe.ts +58 -0
  93. package/src/core/recall/session.ts +27 -3
  94. package/src/core/recall/time-ask.ts +116 -18
  95. package/src/core/remember/CONTRACT.md +4 -1
  96. package/src/core/remember/INTERFACE-GAPS.md +9 -1
  97. package/src/core/remember/proposals.ts +38 -5
  98. package/src/core/revision.ts +5 -0
  99. package/src/core/schemas/CONTRACT.md +13 -1
  100. package/src/core/schemas/INTERFACE-GAPS.md +20 -2
  101. package/src/core/schemas/NOTES.md +127 -0
  102. package/src/core/schemas/types.ts +2 -0
  103. package/src/core/self/CONTRACT.md +15 -4
  104. package/src/core/self/INTERFACE-GAPS.md +7 -2
  105. package/src/core/self/NOTES.md +49 -0
  106. package/src/core/self/briefing.ts +12 -2
  107. package/src/core/self/index.ts +82 -8
  108. package/src/core/self/page.ts +88 -0
  109. package/src/core/sleep/INTERFACE-GAPS.md +22 -3
  110. package/src/core/sleep/NOTES.md +11 -0
  111. package/src/core/sleep/prune.ts +6 -2
  112. package/src/core/store/NOTES.md +14 -0
  113. package/src/core/store/index.ts +107 -0
  114. package/src/core/time.ts +152 -0
  115. package/tools/install-loop/run.sh +48 -12
  116. 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
 
@@ -478,7 +538,12 @@ export const MECHANISMS: readonly Mechanism[] = [
478
538
  id: "result-cut",
479
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",
480
540
  module: "mcp/server.ts (withinCeiling)",
541
+ cadence: { kind: "occasion", when: "a tool answer comes out too long for the host to show" },
481
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"],
482
547
  since: "2026-10-02",
483
548
  },
484
549
  {
@@ -597,15 +662,19 @@ export const MECHANISMS: readonly Mechanism[] = [
597
662
  id: "core-demote",
598
663
  label: "the owner sent a core memory back to ordinary fading, and said why",
599
664
  module: "counterpart.ts#demoteCore",
665
+ cadence: { kind: "occasion", when: "the owner sends a core memory back" },
600
666
  evidence: { kind: "event", names: ["band.demoted"] },
601
667
  since: "2026-09-26",
602
668
  },
603
669
  {
604
670
  // The v8 upgrade's one-time proof: every memory measured by the old
605
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.
606
674
  id: "upgrade-census",
607
675
  label: "after the v8 upgrade, every memory was checked by the old rules and the new",
608
676
  module: "sleep/upgrade.ts",
677
+ cadence: { kind: "one-time", when: "a store made before v8 is upgraded" },
609
678
  evidence: { kind: "event", names: ["physics.upgrade.census"] },
610
679
  since: "2026-09-26",
611
680
  },
@@ -618,9 +687,27 @@ export const MECHANISMS: readonly Mechanism[] = [
618
687
  // `no-similarity-supplied` is the embedder being off, which fires for EVERY
619
688
  // pair on the default configuration and already has its own amber on
620
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.
621
704
  id: "dedup",
622
- 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",
623
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
+ },
624
711
  evidence: { kind: "event", names: ["memory.merged"] },
625
712
  refusals: {
626
713
  names: ["sleep.cycle"],
@@ -630,10 +717,15 @@ export const MECHANISMS: readonly Mechanism[] = [
630
717
  },
631
718
  },
632
719
  {
633
- // 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
634
721
  // forgotten; `in-live-revision-chain` is a live chain holding a row that
635
- // the floor would otherwise have let go. Both are a rule refusing a memory
636
- // 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`
637
729
  // are the ordinary condition of almost every memory on almost every night —
638
730
  // the reviewer measured `dwell-too-short ×240` on a healthy forty-memory
639
731
  // store after seven boundaries.
@@ -644,7 +736,7 @@ export const MECHANISMS: readonly Mechanism[] = [
644
736
  refusals: {
645
737
  names: ["sleep.cycle"],
646
738
  under: "prune/blocked:",
647
- only: ["protected", "in-live-revision-chain"],
739
+ only: ["protected", "in-live-revision-chain", "recurring"],
648
740
  since: "2026-09-20",
649
741
  },
650
742
  },
@@ -677,6 +769,7 @@ export const MECHANISMS: readonly Mechanism[] = [
677
769
  id: "revision",
678
770
  label: "a belief took a credited challenge and was revised under the pressure",
679
771
  module: "schemas/index.ts",
772
+ cadence: { kind: "occasion", when: "a belief takes a credited challenge" },
680
773
  evidence: { kind: "event", names: ["revision.pressure"] },
681
774
  },
682
775
  {
@@ -687,8 +780,9 @@ export const MECHANISMS: readonly Mechanism[] = [
687
780
  id: "contradictions",
688
781
  label: "two memories that disagree were settled — changed, corrected or kept open — or flagged, or a settle undone",
689
782
  module: "core/contradictions.ts (revision.ts, dream/, mcp note, cli settle)",
783
+ cadence: { kind: "occasion", when: "two memories disagree" },
690
784
  evidence: { kind: "event", names: ["contradiction.settled"] },
691
- covers: ["contradiction.flagged", "contradiction.undone"],
785
+ covers: ["contradiction.flagged", "contradiction.undone", "contradiction.held"],
692
786
  since: "2026-09-29",
693
787
  },
694
788
  {
@@ -834,7 +928,7 @@ export const MECHANISMS: readonly Mechanism[] = [
834
928
  },
835
929
  {
836
930
  id: "wake-delivered",
837
- 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",
838
932
  module: "claude-code/hooks.ts",
839
933
  evidence: { kind: "event", names: ["adapter.wake.delivered"] },
840
934
  },
@@ -849,6 +943,7 @@ export const MECHANISMS: readonly Mechanism[] = [
849
943
  id: "protection",
850
944
  label: "the owner marked a memory permanent, so nothing may revise or forget it",
851
945
  module: "physics/, store/",
946
+ cadence: { kind: "occasion", when: "the owner marks a memory permanent" },
852
947
  evidence: {
853
948
  kind: "probe",
854
949
  probe: "protected",
@@ -860,12 +955,14 @@ export const MECHANISMS: readonly Mechanism[] = [
860
955
  id: "removal",
861
956
  label: "the owner erased a memory, and the erasure left a record",
862
957
  module: "store/owner-op-seam.ts",
958
+ cadence: { kind: "occasion", when: "the owner erases a memory" },
863
959
  evidence: { kind: "probe", probe: "removals" },
864
960
  },
865
961
  {
866
962
  id: "unmerge",
867
963
  label: "the owner put back a memory a merge had archived",
868
964
  module: "store/owner-op-seam.ts",
965
+ cadence: { kind: "occasion", when: "the owner puts back a memory a merge archived" },
869
966
  evidence: { kind: "event", names: ["memory.unmerged"] },
870
967
  },
871
968
  {
@@ -896,6 +993,7 @@ export const MECHANISMS: readonly Mechanism[] = [
896
993
  id: "prospective-fired",
897
994
  label: "that future date arrived and the reminder came back",
898
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" },
899
997
  evidence: { kind: "event", names: ["prospective.fire"] },
900
998
  // The refusal row is ACCOUNTED FOR here, and deliberately not read as a
901
999
  // refusal column: its reasons are budget and calendar ("already fired
@@ -907,9 +1005,16 @@ export const MECHANISMS: readonly Mechanism[] = [
907
1005
  {
908
1006
  // A PLAIN reminder told to the person on its day (2026-09-26): one row per
909
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.
910
1014
  id: "prospective-plain",
911
1015
  label: "a reminder marked plain was said plainly on its day",
912
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" },
913
1018
  evidence: { kind: "event", names: ["prospective.plain"] },
914
1019
  since: "2026-09-26",
915
1020
  },
@@ -949,6 +1054,7 @@ export const MECHANISMS: readonly Mechanism[] = [
949
1054
  id: "worker-trouble",
950
1055
  label: "the worker was refused, could not be started, or failed after starting",
951
1056
  module: "lifecycle.ts, bin/runner.ts",
1057
+ cadence: { kind: "occasion", when: "the worker is refused, cannot start, or fails" },
952
1058
  evidence: {
953
1059
  kind: "event",
954
1060
  names: ["adapter.spawn.refused", "adapter.spawn.failed", "adapter.runner.failed"],
@@ -991,6 +1097,7 @@ export const MECHANISMS: readonly Mechanism[] = [
991
1097
  id: "snapshot-trouble",
992
1098
  label: "a copy of the store could not be made (the store itself is unharmed)",
993
1099
  module: "adapters/snapshots.ts",
1100
+ cadence: { kind: "occasion", when: "a copy of the store fails" },
994
1101
  evidence: { kind: "event", names: ["snapshot.failed"] },
995
1102
  since: "2026-09-18",
996
1103
  },
@@ -1048,6 +1155,7 @@ export const MECHANISMS: readonly Mechanism[] = [
1048
1155
  id: "export",
1049
1156
  label: "the owner took a readable copy of the memories off this machine, by hand",
1050
1157
  module: "cli/export.ts",
1158
+ cadence: { kind: "occasion", when: "the owner exports" },
1051
1159
  evidence: { kind: "event", names: ["store.export"] },
1052
1160
  since: "2026-09-20",
1053
1161
  },
@@ -1073,8 +1181,17 @@ export interface FiredRow {
1073
1181
  readonly topRefusal: string | null;
1074
1182
  /** The dotted names or the table this row was read from, for the reader who greps. */
1075
1183
  readonly evidence: string;
1076
- /** 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. */
1077
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;
1078
1195
  }
1079
1196
 
1080
1197
  export interface FiredReport {
@@ -1110,6 +1227,14 @@ export interface FiredReport {
1110
1227
  * finding read greener.
1111
1228
  */
1112
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[];
1113
1238
  /** The store's own clock — the number of days it has actually LIVED. */
1114
1239
  readonly livedDay: number;
1115
1240
  /** Calendar days between the oldest row this pass read and today, or null
@@ -1198,12 +1323,19 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
1198
1323
 
1199
1324
  const rows: FiredRow[] = [];
1200
1325
  const notRead: string[] = [];
1326
+ const missedOccasion: string[] = [];
1201
1327
  for (const m of MECHANISMS) {
1202
1328
  if (m.evidence.kind === "probe" && probed === null) {
1203
1329
  notRead.push(m.id);
1204
1330
  continue;
1205
1331
  }
1206
- 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})`);
1207
1339
  }
1208
1340
 
1209
1341
  const counts = Object.fromEntries(FIRED_STATES.map((s) => [s, 0])) as Record<FiredState, number>;
@@ -1240,8 +1372,11 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
1240
1372
  !comparisonIsTooYoung(r.id, window),
1241
1373
  )
1242
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,
1243
1378
  wentQuiet: rows
1244
- .filter((r) => r.state === "quiet" && r.firedInPreviousWindow > 0)
1379
+ .filter((r) => r.state === "quiet" && r.firedInPreviousWindow > 0 && r.occasionMissed === 0)
1245
1380
  // A row whose table keeps only LIVED days was compared on the lived clock,
1246
1381
  // which has run seven days across fifteen calendar ones — so the sentence
1247
1382
  // says which clock answered rather than claiming a calendar week it did
@@ -1312,9 +1447,15 @@ const EMPTY_READING: Reading = {
1312
1447
  blind: null,
1313
1448
  };
1314
1449
 
1315
- 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 {
1316
1457
  const read = readEvidence(m, log, probed);
1317
- const state = stateOf(m, read, w);
1458
+ const state = stateOf(m, read, w, occasion);
1318
1459
  return {
1319
1460
  id: m.id,
1320
1461
  label: m.label,
@@ -1328,7 +1469,9 @@ function rowFor(m: Mechanism, log: LogRead, probed: Probed | null, w: Window): F
1328
1469
  refusedInWindow: read.refused,
1329
1470
  topRefusal: read.topRefusal,
1330
1471
  evidence: read.evidence,
1331
- note: noteFor(m, read, state),
1472
+ note: noteFor(m, read, state, occasion),
1473
+ cadence: m.cadence?.kind ?? null,
1474
+ occasionMissed: occasion?.missed ?? 0,
1332
1475
  };
1333
1476
  }
1334
1477
 
@@ -1338,7 +1481,7 @@ function rowFor(m: Mechanism, log: LogRead, probed: Probed | null, w: Window): F
1338
1481
  * count; blindness is a fact about the EVIDENCE and outranks the rest; only then
1339
1482
  * do the counts speak.
1340
1483
  */
1341
- function stateOf(m: Mechanism, read: Reading, w: Window): FiredState {
1484
+ function stateOf(m: Mechanism, read: Reading, w: Window, occasion: OccasionReading | null = null): FiredState {
1342
1485
  if (m.disabled !== undefined) return "disabled";
1343
1486
  if (m.retired !== undefined) return "retired";
1344
1487
  if (read.blind !== null) return "blind";
@@ -1347,7 +1490,17 @@ function stateOf(m: Mechanism, read: Reading, w: Window): FiredState {
1347
1490
  // `never` because it answers the question they leave open: a mechanism that
1348
1491
  // was turned away every time it was reached is not one that had nothing to do.
1349
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";
1350
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";
1351
1504
  // Never fired. A mechanism whose EVIDENCE is younger than the window has not
1352
1505
  // had time to be a worry yet, and grading it as one is how a view teaches its
1353
1506
  // reader to ignore it.
@@ -1355,10 +1508,29 @@ function stateOf(m: Mechanism, read: Reading, w: Window): FiredState {
1355
1508
  return "never";
1356
1509
  }
1357
1510
 
1358
- 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 {
1359
1517
  if (state === "disabled") return m.disabled ?? null;
1360
1518
  if (state === "retired") return m.retired ?? null;
1361
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
+ }
1362
1534
  if (state === "new" && m.since !== undefined) return `its evidence was added ${m.since}`;
1363
1535
  if (state === "blocked") {
1364
1536
  // The whole point of the state, in one sentence: not "quiet", not "never" —
@@ -1484,8 +1656,38 @@ interface LogRead {
1484
1656
  /** The calendar date of the OLDEST row this pass saw, for the store's age.
1485
1657
  * A truncated read is the oldest rows, so this stays right when it happens. */
1486
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>;
1487
1675
  }
1488
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;
1683
+ }
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
+
1489
1691
  /**
1490
1692
  * The tally key for a name read through a `positive` filter. A character no
1491
1693
  * durable event name carries, so it cannot collide with a real one.
@@ -1535,11 +1737,11 @@ function emptyTally(): NameTally {
1535
1737
  */
1536
1738
  function readLog(store: ReadOnlyStore, w: Window): LogRead {
1537
1739
  const byName = new Map<string, NameTally>();
1538
- const age = { oldest: null as string | null };
1740
+ const age: PassState = { oldest: null, presence: [], attended: new Map() };
1539
1741
  const first = store.eventLog({ limit: EVENT_CEILING });
1540
1742
  for (const row of first) tallyRow(byName, row, w, age);
1541
1743
  if (first.length < EVENT_CEILING) {
1542
- return { byName, truncated: false, oldestDate: age.oldest };
1744
+ return { byName, truncated: false, oldestDate: age.oldest, presence: age.presence, attended: age.attended };
1543
1745
  }
1544
1746
  const lastSeq = first[first.length - 1]?.seq ?? 0;
1545
1747
  // A lived day is never longer than a calendar day, so `livedDay - 14` cannot
@@ -1552,18 +1754,30 @@ function readLog(store: ReadOnlyStore, w: Window): LogRead {
1552
1754
  if (row.seq <= lastSeq) continue;
1553
1755
  tallyRow(byName, row, w, age);
1554
1756
  }
1555
- return { byName, truncated: true, oldestDate: age.oldest };
1757
+ return { byName, truncated: true, oldestDate: age.oldest, presence: age.presence, attended: age.attended };
1556
1758
  }
1557
1759
 
1558
- function tallyRow(
1559
- byName: Map<string, NameTally>,
1560
- row: EventRow,
1561
- w: Window,
1562
- age: { oldest: string | null },
1563
- ): 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 {
1564
1768
  const payload = payloadOf(row);
1565
1769
  const date = rowDate(row, payload, w.zone);
1566
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
+ }
1567
1781
  const t = countInto(byName, row.name, date, w);
1568
1782
  // THE FILTERED TALLIES, in the same pass (`Evidence.positive`). They count
1569
1783
  // the row and NOTHING ELSE: the refusal reader below answers for every phase
@@ -1748,6 +1962,177 @@ function str(p: Record<string, unknown>, key: string): string | null {
1748
1962
  return typeof v === "string" && v.length > 0 ? v : null;
1749
1963
  }
1750
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
+
1751
2136
  // ── the table probes ────────────────────────────────────────────────────────
1752
2137
 
1753
2138
  interface ProbeTally {