counterparts 0.3.1 → 0.3.2

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 (179) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/docs/module-map.md +2 -0
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/NOTES.md +32 -0
  5. package/src/adapters/claude-code/bin/hook.ts +15 -2
  6. package/src/adapters/claude-code/bin/runner.ts +3 -1
  7. package/src/adapters/claude-code/config.ts +23 -0
  8. package/src/adapters/claude-code/doctor.ts +39 -20
  9. package/src/adapters/claude-code/hooks.ts +32 -12
  10. package/src/adapters/claude-code/index.ts +1 -0
  11. package/src/adapters/cli/commands.ts +178 -59
  12. package/src/adapters/cli/export.ts +27 -3
  13. package/src/adapters/cli/help.ts +22 -8
  14. package/src/adapters/cli/install.ts +3 -5
  15. package/src/adapters/cli/mechanisms.ts +295 -0
  16. package/src/adapters/cli/repair-dates.ts +3 -1
  17. package/src/adapters/dashboard/CONTRACT.md +13 -9
  18. package/src/adapters/dashboard/NOTES.md +3 -2
  19. package/src/adapters/dashboard/activity.ts +2 -1
  20. package/src/adapters/dashboard/bin/dashboard.ts +18 -3
  21. package/src/adapters/dashboard/upgrade.ts +23 -0
  22. package/src/adapters/dashboard/web/README.md +153 -0
  23. package/src/adapters/dashboard/web/actions.ts +631 -0
  24. package/src/adapters/dashboard/web/app.html +40 -1703
  25. package/src/adapters/dashboard/web/app.js +55 -0
  26. package/src/adapters/dashboard/web/mechanisms/association/index.js +15 -0
  27. package/src/adapters/dashboard/web/mechanisms/association/panel.js +17 -0
  28. package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +15 -0
  29. package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +23 -0
  30. package/src/adapters/dashboard/web/mechanisms/decay/index.js +15 -0
  31. package/src/adapters/dashboard/web/mechanisms/decay/panel.js +45 -0
  32. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +15 -0
  33. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +15 -0
  34. package/src/adapters/dashboard/web/mechanisms/index.js +60 -0
  35. package/src/adapters/dashboard/web/mechanisms/interference/index.js +15 -0
  36. package/src/adapters/dashboard/web/mechanisms/picture.js +28 -0
  37. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +15 -0
  38. package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +15 -0
  39. package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +15 -0
  40. package/src/adapters/dashboard/web/mechanisms/regions.js +30 -0
  41. package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +15 -0
  42. package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +20 -0
  43. package/src/adapters/dashboard/web/mechanisms/salience/index.js +15 -0
  44. package/src/adapters/dashboard/web/mechanisms/salience/panel.js +14 -0
  45. package/src/adapters/dashboard/web/mechanisms/schema/index.js +15 -0
  46. package/src/adapters/dashboard/web/narrate.ts +10 -10
  47. package/src/adapters/dashboard/web/pages/flow/flow.css +38 -0
  48. package/src/adapters/dashboard/web/pages/flow/index.js +117 -0
  49. package/src/adapters/dashboard/web/pages/flow/sections/blind.js +12 -0
  50. package/src/adapters/dashboard/web/pages/flow/sections/detail.js +45 -0
  51. package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +291 -0
  52. package/src/adapters/dashboard/web/pages/flow/sections/feed.js +11 -0
  53. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +41 -0
  54. package/src/adapters/dashboard/web/pages/flow/sections/heatmap.js +25 -0
  55. package/src/adapters/dashboard/web/pages/flow/sections/records.js +24 -0
  56. package/src/adapters/dashboard/web/pages/flow/sections/symmetry.js +17 -0
  57. package/src/adapters/dashboard/web/pages/flow/state.js +3 -0
  58. package/src/adapters/dashboard/web/pages/health/health.css +93 -0
  59. package/src/adapters/dashboard/web/pages/health/index.js +41 -0
  60. package/src/adapters/dashboard/web/pages/health/sections/archive.js +84 -0
  61. package/src/adapters/dashboard/web/pages/health/sections/checks.js +172 -0
  62. package/src/adapters/dashboard/web/pages/health/sections/cycle.js +37 -0
  63. package/src/adapters/dashboard/web/pages/health/sections/verify.js +54 -0
  64. package/src/adapters/dashboard/web/pages/home/brain.js +375 -0
  65. package/src/adapters/dashboard/web/pages/home/home.css +134 -0
  66. package/src/adapters/dashboard/web/pages/home/index.js +84 -0
  67. package/src/adapters/dashboard/web/pages/home/sections/explorer.js +206 -0
  68. package/src/adapters/dashboard/web/pages/home/sections/hero.js +22 -0
  69. package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +25 -0
  70. package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +13 -0
  71. package/src/adapters/dashboard/web/pages/home/sections/tiles.js +52 -0
  72. package/src/adapters/dashboard/web/pages/memories/index.js +75 -0
  73. package/src/adapters/dashboard/web/pages/memories/memories.css +143 -0
  74. package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +178 -0
  75. package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +42 -0
  76. package/src/adapters/dashboard/web/pages/memories/sections/list.js +114 -0
  77. package/src/adapters/dashboard/web/pages/memories/sections/search.js +102 -0
  78. package/src/adapters/dashboard/web/pages/memories/sections/tools.js +155 -0
  79. package/src/adapters/dashboard/web/pages/memories/state.js +22 -0
  80. package/src/adapters/dashboard/web/pages/self/diff.js +79 -0
  81. package/src/adapters/dashboard/web/pages/self/index.js +43 -0
  82. package/src/adapters/dashboard/web/pages/self/markdown.js +61 -0
  83. package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -0
  84. package/src/adapters/dashboard/web/pages/self/sections/page.js +149 -0
  85. package/src/adapters/dashboard/web/pages/self/sections/settling.js +150 -0
  86. package/src/adapters/dashboard/web/pages/self/sections/stories.js +47 -0
  87. package/src/adapters/dashboard/web/pages/self/sections/wake.js +74 -0
  88. package/src/adapters/dashboard/web/pages/self/self.css +182 -0
  89. package/src/adapters/dashboard/web/server.ts +305 -28
  90. package/src/adapters/dashboard/web/shared/absence.js +14 -0
  91. package/src/adapters/dashboard/web/shared/actions.js +48 -0
  92. package/src/adapters/dashboard/web/shared/api.js +17 -0
  93. package/src/adapters/dashboard/web/shared/base.css +34 -0
  94. package/src/adapters/dashboard/web/shared/canvas.js +68 -0
  95. package/src/adapters/dashboard/web/shared/colors.js +6 -0
  96. package/src/adapters/dashboard/web/shared/dom.js +4 -0
  97. package/src/adapters/dashboard/web/shared/event-modal.js +25 -0
  98. package/src/adapters/dashboard/web/shared/fonts/OFL-courier-prime.txt +93 -0
  99. package/src/adapters/dashboard/web/shared/fonts/OFL-outfit.txt +93 -0
  100. package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-400.woff2 +0 -0
  101. package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-700.woff2 +0 -0
  102. package/src/adapters/dashboard/web/shared/fonts/outfit-latin-wght.woff2 +0 -0
  103. package/src/adapters/dashboard/web/shared/format.js +31 -0
  104. package/src/adapters/dashboard/web/shared/layout.css +32 -0
  105. package/src/adapters/dashboard/web/shared/memory-modal.js +124 -0
  106. package/src/adapters/dashboard/web/shared/modal.css +24 -0
  107. package/src/adapters/dashboard/web/shared/modal.js +22 -0
  108. package/src/adapters/dashboard/web/shared/state.js +12 -0
  109. package/src/adapters/dashboard/web/shared/tip.css +4 -0
  110. package/src/adapters/dashboard/web/shared/tip.js +12 -0
  111. package/src/adapters/dashboard/web/shared/tokens.css +50 -0
  112. package/src/adapters/dashboard/web/shared/type.css +52 -0
  113. package/src/adapters/dashboard/web/shared/utilities.css +5 -0
  114. package/src/adapters/dashboard/web/shared/vendor/MIT-three.txt +21 -0
  115. package/src/adapters/dashboard/web/shared/vendor/three.module.min.js +6 -0
  116. package/src/adapters/dashboard/web/shared/widgets/bar.css +9 -0
  117. package/src/adapters/dashboard/web/shared/widgets/card.css +6 -0
  118. package/src/adapters/dashboard/web/shared/widgets/chapters.js +15 -0
  119. package/src/adapters/dashboard/web/shared/widgets/chart.css +4 -0
  120. package/src/adapters/dashboard/web/shared/widgets/confirm.css +31 -0
  121. package/src/adapters/dashboard/web/shared/widgets/confirm.js +52 -0
  122. package/src/adapters/dashboard/web/shared/widgets/feed.css +13 -0
  123. package/src/adapters/dashboard/web/shared/widgets/feed.js +41 -0
  124. package/src/adapters/dashboard/web/shared/widgets/light.css +4 -0
  125. package/src/adapters/dashboard/web/shared/widgets/light.js +15 -0
  126. package/src/adapters/dashboard/web/shared/widgets/rows.css +7 -0
  127. package/src/adapters/dashboard/web/shared/widgets/table.css +17 -0
  128. package/src/adapters/dashboard/web/shared/widgets/tiles.css +14 -0
  129. package/src/adapters/dashboard/web/shell/pages.js +15 -0
  130. package/src/adapters/dashboard/web/shell/pulse.js +86 -0
  131. package/src/adapters/dashboard/web/shell/tabs.js +49 -0
  132. package/src/adapters/dashboard/web/static.ts +76 -0
  133. package/src/adapters/dashboard/web/views/activity.ts +80 -0
  134. package/src/adapters/dashboard/web/views/archive-words.ts +57 -0
  135. package/src/adapters/dashboard/web/views/flow-view.ts +217 -0
  136. package/src/adapters/dashboard/web/views/health.ts +328 -0
  137. package/src/adapters/dashboard/web/views/mechanism-panel.ts +370 -0
  138. package/src/adapters/dashboard/web/views/mechanisms.ts +302 -0
  139. package/src/adapters/dashboard/web/views/memories.ts +342 -0
  140. package/src/adapters/dashboard/web/views/memory.ts +210 -0
  141. package/src/adapters/dashboard/web/views/meta.ts +64 -0
  142. package/src/adapters/dashboard/web/views/mind.ts +729 -0
  143. package/src/adapters/dashboard/web/views/overview.ts +282 -0
  144. package/src/adapters/dashboard/web/views/pulse.ts +19 -0
  145. package/src/adapters/dashboard/web/views/rows.ts +207 -0
  146. package/src/adapters/dashboard/web/views/search.ts +62 -0
  147. package/src/adapters/dashboard/web/views/shared.ts +161 -0
  148. package/src/adapters/dashboard/web/views.ts +34 -1724
  149. package/src/adapters/fired.ts +28 -17
  150. package/src/adapters/mcp/NOTES.md +43 -0
  151. package/src/adapters/mcp/bin/serve.ts +5 -1
  152. package/src/adapters/mcp/index.ts +3 -0
  153. package/src/adapters/mcp/server.ts +163 -6
  154. package/src/adapters/mcp/tools.ts +42 -0
  155. package/src/adapters/mcp/write-up.ts +1 -1
  156. package/src/core/counterpart.ts +30 -1
  157. package/src/core/feelings-wheel.ts +218 -0
  158. package/src/core/mint.ts +14 -2
  159. package/src/core/prospective/INTERFACE-GAPS.md +10 -0
  160. package/src/core/prospective/windows.ts +10 -48
  161. package/src/core/self/NOTES.md +17 -0
  162. package/src/core/self/calendar.ts +7 -78
  163. package/src/core/self/episodes.ts +7 -8
  164. package/src/core/self/index.ts +32 -11
  165. package/src/core/self/writer.ts +22 -22
  166. package/src/core/sleep/cycle.ts +8 -2
  167. package/src/core/store/CONTRACT.md +26 -7
  168. package/src/core/store/NOTES.md +142 -0
  169. package/src/core/store/errors.ts +15 -0
  170. package/src/core/store/feelings.ts +182 -0
  171. package/src/core/store/index.ts +297 -45
  172. package/src/core/store/operational.ts +133 -11
  173. package/src/core/store/owner-op-seam.ts +13 -3
  174. package/src/core/store/pre-migration.ts +3 -1
  175. package/src/core/store/prose.ts +8 -1
  176. package/src/core/store/render.ts +3 -0
  177. package/src/core/time.ts +374 -0
  178. package/src/core/types.ts +13 -0
  179. package/src/adapters/dashboard/web/brain.html +0 -463
package/CHANGELOG.md CHANGED
@@ -1,6 +1,54 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.1 — unreleased
3
+ ## 0.3.2 — 2026-09-25
4
+
5
+ Dates and times follow your clock, and the store's format moves to v7.
6
+
7
+ **Before upgrading, close every Claude Code session.** The first session after the upgrade
8
+ saves a copy of the store and then updates its format; a session left open is still
9
+ running the old memory server, so in any you missed, run `/mcp` and choose Reconnect.
10
+ If your store is not in the default place (a `dataDir` outside `~/.counterparts/store`,
11
+ or `COUNTERPARTS_DATA_DIR`), set `snapshots.dir` in the config first: the upgrade will
12
+ not run without somewhere to save that copy, and memory stays off until it is set
13
+ (`doctor` says so).
14
+
15
+ - **Your day is your local day.** The day a memory was learned, "today", and the dates
16
+ in `doctor` and `counterparts fired` now use this computer's time zone instead of UTC,
17
+ so a memory saved at 11:50 pm belongs to that evening. Console commands read the zone
18
+ from the config beside the store, as the hooks do. Memories saved before keep the
19
+ dates they have. A `timeZone` setting in the config (for example `"America/Denver"`)
20
+ pins a zone, for a machine set to UTC; install says which zone it found.
21
+ - **Sessions know what time it is.** The wake opens with a line like
22
+ `Now: Fri 25 Sep 2026, 1:40 pm MDT`, and every turn carries the current time too.
23
+ - **Each memory records when it was written and changed, and which model wrote it.**
24
+ Notes, end-of-session memories, journal chapters and the self page carry the model the
25
+ session was using.
26
+ - **Feelings can be recorded on a memory** — several per memory, yours and Claude's side
27
+ by side, each named on a feelings wheel (six core emotions and the finer words under
28
+ them) with a strength and what carried it. `note` and `session_end` take them; a word
29
+ not on the wheel is kept, and the reply suggests the nearest ones. They change nothing
30
+ about how memories are held yet.
31
+ - **The store can hold a reminder's date** — a day, a month, or a range like
32
+ `2026-10-20..2026-10-31` — ready for reminders to use in a later release.
33
+ - One module now does every date conversion, and a test keeps it that way.
34
+
35
+ **A new dashboard** (`counterparts dashboard`):
36
+
37
+ - **A new home page**: the brain beside a few plain counts, and the 11 mechanisms the
38
+ site describes, each lit when it is working. Click one to see what it did lately.
39
+ - **Memories**: every memory in a list, newest first, with search, Ask, and filters for
40
+ kind, band and archived.
41
+ - **Self**: the self page with its history, what is settling into the core, the
42
+ briefing for the next session, and the journal by day.
43
+ - **Health**: "is it working?" as a checklist from `doctor`, the last sleep cycle, and
44
+ where archived memories went.
45
+ - **Manage memory from the dashboard**: write a note, remove a memory, back up, export,
46
+ rebrief, check the index, and ask, through the same code as the console. Removing
47
+ asks you to confirm first.
48
+ - The site's fonts, served from the package.
49
+ - A store waiting for its upgrade shows a short page saying so, instead of an error.
50
+
51
+ ## 0.3.1 — 2026-09-25
4
52
 
5
53
  A small release of fixes. No change to the store's format, so no migration and no
6
54
  Reconnect.
@@ -23,6 +23,8 @@ code and the `NOTES.md` / `INTERFACE-GAPS.md` next to it.*
23
23
  | `prospective/` | prospective memory | Future intentions, cued by time or context; fire / suppress / reference telemetry. |
24
24
  | `handoff/` | working context for a place | The per-directory handoff: where the work here stands, written as a field on the end-of-session ask, shown as a two-line pointer at the next wake in that directory, expiring in lived days. **Never a memory** — out of recall, out of credit, out of consolidation, out of identity. **Added 2026-09-20 (E1, spec §6.4 / §15 item 6).** |
25
25
  | `sleep/` | systems consolidation | Pure math on a cycle: decay tick (active-day clock), floor-pruning (real forgetting), re-render of the wake briefing. Zero standing model calls. |
26
+ | *(`time.ts`)* | — (a clock, not a memory) | The one module that converts: a moment (UTC ms from `store.now()`) to a person's local date or clock line, "today" in a zone, and calendar dates as said (day, month, year, range). A file, not a module; a test keeps hand-built dates out of `src/`. **Added 2026-09-25 (`docs/time.md`).** |
27
+ | *(`feelings-wheel.ts`)* | — (a vocabulary) | The feelings wheel as a typed list: six cores, the middle and outer rings, valence, and the key scheme (`<core>.<word>` only for a word printed under two cores). Read by `store/` to validate the `feelings` table. **Added 2026-09-25.** |
26
28
  | *(observer)* | — (instrument stance) | **RESOLVED (owner, 2026-08-25): a MODE, not a module** — one predicate threaded through the core API, checked at the store seam. Spec moved to `docs/observer-mode.md`. |
27
29
 
28
30
  **Third open question (check-in): the `remember`/`encode` boundary.** With the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "license": "MIT",
5
5
  "description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
6
6
  "repository": {
@@ -1561,3 +1561,35 @@ What the build settled, beyond the CONTRACT section:
1561
1561
  are the item's; anything else keeps the paid-shaped rules (limit 64, blame only an
1562
1562
  item the embedder named). Core's `no-credential` / `no-credentials` reasons are left in
1563
1563
  its vocabulary, because rows already written carry them.
1564
+
1565
+ ## 2026-09-25 — the person's clock (docs/time.md)
1566
+
1567
+ - **`timeZone` in the config** (optional, an IANA name) is read leniently: a name this
1568
+ machine does not know is ignored, kept as `timeZoneUnknown`, and named on doctor's Clock
1569
+ line — a misspelt zone must not stand memory down the way an unreadable setting does.
1570
+ It reaches the store through `Counterpart.open({ timeZone })` in `openAdapter`, the
1571
+ runner, and the MCP entry point.
1572
+ - **The hook's `at` is the person's day** (`bin/hook.ts#toHookInput`, `todayIn(zone)`),
1573
+ so the rows it dates, the wake preface's date, prospective's "today" and the date the
1574
+ boundary hands the lived clock are local. The evening-of-the-upgrade case (a local date
1575
+ one day behind the last UTC one) is store NOTES 2026-09-25: refused, named, the day
1576
+ holds.
1577
+ - **The wake's first line is `Now: Fri 25 Sep 2026, 1:40 pm MDT`**, and a turn that
1578
+ recalls something carries the same line above its note. Both sit OUTSIDE the block they
1579
+ precede, so the wake's byte count, its two sentinels and the preface reserve are
1580
+ untouched, and the delivery check (which finds sentinels by prefix) reads as before.
1581
+ The line's bytes are counted wherever the host's ceiling is: `sent`, not `woke.bytes`,
1582
+ decides the over-budget event and the room an ask may take. `bytes` in the result is
1583
+ still the wake's own count. **Every turn** prints the line — alone when recall surfaced
1584
+ nothing, and on an empty prompt (owner, 2026-09-25: ~40 bytes a turn is fine). A
1585
+ primacy stand-down still prints nothing: a muted session is muted.
1586
+ - **Doctor**: the header lost its "(UTC)"; the Clock line names the zone in use
1587
+ (`today 2026-09-25 (America/Denver)`). `rowDate`'s fallback, the oldest-event and
1588
+ database-birth days, and the page's staleness read that zone.
1589
+ - **Install** says the zone in one line after the name question and asks nothing:
1590
+ "Times read in America/Denver, this computer's zone — "timeZone" in the config pins
1591
+ another."
1592
+
1593
+ - **Review of #231, S1 (2026-09-25):** the evening of the upgrade no longer turns doctor
1594
+ RED. The store holds a one-day-back date as the same lived day, and the migration
1595
+ clamps `lastActiveDate`; details are in store NOTES.
@@ -35,6 +35,7 @@ import {
35
35
  } from "../../scopes.js";
36
36
  import type { ScopeRead, ScopeVerdict } from "../../scopes.js";
37
37
  import { canonicalScope, readSession } from "../../sessions.js";
38
+ import { resolveZone, todayIn } from "../../../core/time.js";
38
39
  import { loadConfig, withEmbedderDefault } from "../config.js";
39
40
  import type { AdapterConfig } from "../config.js";
40
41
  import { HOOKS, openAdapter } from "../index.js";
@@ -363,6 +364,8 @@ export function toHookInput(
363
364
  readonly scope?: string;
364
365
  readonly dataDir?: string;
365
366
  readonly env?: NodeJS.ProcessEnv;
367
+ /** The config's `timeZone`; absent, the machine's current zone. */
368
+ readonly timeZone?: string;
366
369
  } = {},
367
370
  ): HookInput {
368
371
  const scope = opts.scope ?? sessionScope(opts.dataDir, payload, opts.env ?? process.env);
@@ -390,7 +393,14 @@ export function toHookInput(
390
393
  // nothing (`hooks.ts#askAtStop`).
391
394
  ...(payload["stop_hook_active"] === true ? { reFired: true } : {}),
392
395
  ...(typeof payload["prompt"] === "string" ? { prompt: payload["prompt"] } : {}),
393
- at: new Date().toISOString().slice(0, 10),
396
+ // THE PERSON'S DAY (docs/time.md, 2026-09-25; UTC before). It dates the
397
+ // hook's rows, the wake preface, the prospective "today" and the date the
398
+ // boundary hands the lived clock — which is why the lived clock can see a
399
+ // date one day BEHIND its last on the evening of an upgrade west of UTC,
400
+ // or after flying west: the store refuses it (`CLOCK_BACKWARDS`), the
401
+ // cycle stays on the day it already believed, and the next local date
402
+ // moves it on (store NOTES 2026-09-25).
403
+ at: todayIn(resolveZone(opts.timeZone)),
394
404
  };
395
405
  }
396
406
 
@@ -707,7 +717,10 @@ async function runHook(
707
717
  // that twice on the hot path. The scope is handed IN rather than resolved
708
718
  // again: it was decided above, the registry verdict was taken on it, and two
709
719
  // resolutions of one value is the shape scar §2.13 is about.
710
- const input = toHookInput(payload, { scope });
720
+ const input = toHookInput(payload, {
721
+ scope,
722
+ ...(loaded.timeZone === undefined ? {} : { timeZone: loaded.timeZone }),
723
+ });
711
724
  const result = adapter.hook(name, input);
712
725
  // THE WORK HAPPENED. Recall was composed, the turn was captured, the session
713
726
  // record was written — whatever this event's job was, `adapter.hook` has
@@ -332,12 +332,14 @@ export async function runOnce(input: {
332
332
  ? {}
333
333
  : { budgetBytes: config.injectionBudgetBytes }),
334
334
  ...(config.owner === undefined ? {} : { owner: config.owner }),
335
+ ...(config.timeZone === undefined ? {} : { timeZone: config.timeZone }),
335
336
  onEvent: (e) => emit(e.name, { ...(e.data ?? {}) }),
336
337
  });
337
338
  // ONE DATE FOR THE WHOLE RUN, resolved before the first step that could
338
339
  // record anything. The `sweep.gate` row carries it; so must every failure row,
339
340
  // or a replay with a pinned date would dedup against the wall clock instead.
340
- const today = input.date ?? new Date().toISOString().slice(0, 10);
341
+ // The person's day, in the store's zone (docs/time.md; UTC before 2026-09-25).
342
+ const today = input.date ?? counterpart.store.today();
341
343
 
342
344
  let lag: LagReport | null = null;
343
345
  let backfill: BackfillReport | null = null;
@@ -25,6 +25,8 @@
25
25
  */
26
26
  import { isAbsolute } from "node:path";
27
27
 
28
+ import { isZone } from "../../core/time.js";
29
+
28
30
  import { PAGE_WRITER_MODES } from "../../core/self/index.js";
29
31
  import type { PageWriterMode } from "../../core/self/index.js";
30
32
  import { DEFAULT_KEEP as SNAPSHOT_DEFAULT_KEEP } from "../snapshots.js";
@@ -225,6 +227,19 @@ export interface AdapterConfig {
225
227
  readonly retired?: readonly string[];
226
228
  /** Is this the owner's own session? Withholding is the safe direction. */
227
229
  readonly owner?: boolean;
230
+ /**
231
+ * THE PERSON'S ZONE, an IANA name (`"America/Denver"`), when it should not
232
+ * follow the computer — a server set to UTC (docs/time.md rule 2). Absent,
233
+ * every local date follows the machine's current zone. Optional, and not
234
+ * asked at install: install prints the zone it detected in one line.
235
+ */
236
+ readonly timeZone?: string;
237
+ /**
238
+ * A `timeZone` this machine does not know, as written. It is IGNORED — the
239
+ * machine's zone is used — and doctor names it; a misspelt zone must not
240
+ * stand anybody's memory down the way an unreadable setting does.
241
+ */
242
+ readonly timeZoneUnknown?: string;
228
243
  /** An instrument stands down. Fail direction: an unreadable config lands here. */
229
244
  readonly observer?: boolean;
230
245
  /** The identity core's name is the OWNER's; there is no default. */
@@ -270,6 +285,8 @@ export function loadConfig(raw: unknown): LoadedConfig {
270
285
  pageWriter?: { mode: PageWriterMode; timeoutMs?: number; ignored?: string[] };
271
286
  retired?: string[];
272
287
  owner?: boolean;
288
+ timeZone?: string;
289
+ timeZoneUnknown?: string;
273
290
  observer?: boolean;
274
291
  identity?: { name: string; aliases?: readonly string[] };
275
292
  } = {};
@@ -332,6 +349,12 @@ export function loadConfig(raw: unknown): LoadedConfig {
332
349
  if (typeof rec["observer"] !== "boolean") unreadable = true;
333
350
  else out.observer = rec["observer"];
334
351
  }
352
+ // Read LENIENTLY, unlike the stance keys above: a zone that is not one is
353
+ // ignored and named, never a reason to stand the configuration down.
354
+ if (rec["timeZone"] !== undefined) {
355
+ if (isZone(rec["timeZone"])) out.timeZone = rec["timeZone"];
356
+ else out.timeZoneUnknown = String(rec["timeZone"]).slice(0, 64);
357
+ }
335
358
  const embedder = rec["embedder"];
336
359
  if (embedder !== undefined) {
337
360
  // The egress knob is read STRICTLY. A misspelled or half-written `embedder`
@@ -32,6 +32,7 @@
32
32
  * nobody needed).
33
33
  */
34
34
  import { spawnSync } from "node:child_process";
35
+ import { addDays, isDay, localDate, resolveZone } from "../../core/time.js";
35
36
  import { existsSync, mkdirSync, rmSync, statSync } from "node:fs";
36
37
  import { homedir } from "node:os";
37
38
  import { dirname, join } from "node:path";
@@ -57,7 +58,6 @@ import {
57
58
  STORE_CREATED_KEY,
58
59
  Store,
59
60
  assertPreMigrationTarget,
60
- dateOf,
61
61
  isStoreError,
62
62
  paths,
63
63
  pendingMigration,
@@ -209,7 +209,8 @@ export interface DoctorInput {
209
209
  readonly dir: string;
210
210
  /** Null when there is no store at `dir` — the store findings then say so. */
211
211
  readonly store: Store | null;
212
- /** Today, UTC, `YYYY-MM-DD` — the same spelling every `date` field uses. */
212
+ /** Today in the person's zone, `YYYY-MM-DD` — the same spelling every `date`
213
+ * field uses (UTC until 2026-09-25; docs/time.md). */
213
214
  readonly today: string;
214
215
  /**
215
216
  * The persisted spawn-refusal counters, `reason -> count`
@@ -779,10 +780,17 @@ function payloadOf(row: EventRow | undefined): Record<string, unknown> {
779
780
 
780
781
  /** The CALENDAR date a row is about: its own field, else the wall clock it was
781
782
  * written at. `day` is the lived-day column and answers a different question. */
783
+ /**
784
+ * The zone this reading names days in — the config's `timeZone`, else the
785
+ * machine's — set once at the top of `doctorFindings` (which is synchronous)
786
+ * so the dozen `rowDate` calls below need no extra argument.
787
+ */
788
+ let readingZone: string = resolveZone(undefined);
789
+
782
790
  function rowDate(row: EventRow | undefined): string | null {
783
791
  if (row === undefined) return null;
784
792
  const p = payloadOf(row);
785
- return typeof p["date"] === "string" && p["date"].length > 0 ? p["date"] : dateOf(row.at);
793
+ return typeof p["date"] === "string" && p["date"].length > 0 ? p["date"] : localDate(row.at, readingZone);
786
794
  }
787
795
 
788
796
  function num(p: Record<string, unknown>, key: string): number | null {
@@ -1312,6 +1320,18 @@ function retentionFindings(input: DoctorInput, store: Store): Finding[] {
1312
1320
  return [finding("retention", "green", TITLE, `${policy} · ${counts}`, "", data)];
1313
1321
  }
1314
1322
 
1323
+ /**
1324
+ * THE ZONE IN USE, on the Clock line (docs/time.md, 2026-09-25): `(America/Denver)`,
1325
+ * and when the config names a zone this machine does not know, that too — it
1326
+ * was ignored, and this is where the owner sees it.
1327
+ */
1328
+ function zoneNote(input: DoctorInput): string {
1329
+ const unknown = input.config.timeZoneUnknown;
1330
+ return unknown === undefined
1331
+ ? `(${readingZone})`
1332
+ : `(${readingZone}; timeZone "${unknown}" in the config is not a zone this machine knows, so it was ignored)`;
1333
+ }
1334
+
1315
1335
  /** The two clocks, and the gap that IS I32's signature. */
1316
1336
  function clockFindings(input: DoctorInput, store: Store): Finding[] {
1317
1337
  const livedDay = store.livedDay();
@@ -1327,13 +1347,13 @@ function clockFindings(input: DoctorInput, store: Store): Finding[] {
1327
1347
  // the clock, so the comparison is not made and the line says why.
1328
1348
  if (read.unknown) {
1329
1349
  const facts =
1330
- `lived day ${livedDay}, lastActiveDate ${lastActive ?? "(unset)"}, today ${input.today} (UTC) — ` +
1350
+ `lived day ${livedDay}, lastActiveDate ${lastActive ?? "(unset)"}, today ${input.today} ${zoneNote(input)} — ` +
1331
1351
  undetermined(BOUNDARY_EVENT);
1332
1352
  return [finding("clock", "green", "Clock", facts, "", data)];
1333
1353
  }
1334
1354
  const facts =
1335
1355
  `lived day ${livedDay}, lastActiveDate ${lastActive ?? "(unset)"}, ` +
1336
- `newest boundary ${boundary ?? "(none)"}, today ${input.today} (UTC)`;
1356
+ `newest boundary ${boundary ?? "(none)"}, today ${input.today} ${zoneNote(input)}`;
1337
1357
  if (boundary !== null && (lastActive === null || lastActive < boundary)) {
1338
1358
  return [
1339
1359
  finding(
@@ -1631,25 +1651,25 @@ function storeFirstDay(store: Store): string | null {
1631
1651
  return readings.length === 0 ? null : readings.reduce((a, b) => (b < a ? b : a));
1632
1652
  }
1633
1653
 
1634
- /** The calendar day (UTC) of the EARLIEST `at` among the store's event rows,
1635
- * or null when it has none, or none that can be read. */
1654
+ /** The calendar day (the person's zone) of the EARLIEST `at` among the store's
1655
+ * event rows, or null when it has none, or none that can be read. */
1636
1656
  function oldestEventDay(store: Store): string | null {
1637
1657
  try {
1638
1658
  const at = store.eventLogCensus().oldestAt;
1639
- return typeof at === "number" && Number.isFinite(at) && at > 0 ? dateOf(at) : null;
1659
+ return typeof at === "number" && Number.isFinite(at) && at > 0 ? localDate(at, readingZone) : null;
1640
1660
  } catch {
1641
1661
  return null;
1642
1662
  }
1643
1663
  }
1644
1664
 
1645
- /** The calendar day (UTC) the store's database file was born, or null when the
1665
+ /** The calendar day (the person's zone) the store's database file was born, or null when the
1646
1666
  * filesystem keeps no birth time — zero, or a "birth" no earlier than the last
1647
1667
  * change, which is what a filesystem without one may report instead. */
1648
1668
  function databaseBirthDay(dir: string): string | null {
1649
1669
  try {
1650
1670
  const stat = statSync(paths.operational(dir));
1651
1671
  const born = stat.birthtimeMs;
1652
- return Number.isFinite(born) && born > 0 && born < stat.ctimeMs ? dateOf(born) : null;
1672
+ return Number.isFinite(born) && born > 0 && born < stat.ctimeMs ? localDate(born, readingZone) : null;
1653
1673
  } catch {
1654
1674
  return null;
1655
1675
  }
@@ -1677,11 +1697,9 @@ function windowPhrase(shown: string, today: string): string {
1677
1697
  return shown === today ? `since ${today}` : `${shown}→${today}`;
1678
1698
  }
1679
1699
 
1680
- /** `YYYY-MM-DD`, `back` days before `today`. UTC, like every date in this store. */
1700
+ /** `YYYY-MM-DD`, `back` days before `today` — label arithmetic (`time.ts`). */
1681
1701
  function daysBefore(today: string, back: number): string {
1682
- const at = Date.parse(`${today}T00:00:00Z`);
1683
- if (Number.isNaN(at)) return today;
1684
- return new Date(at - back * 86_400_000).toISOString().slice(0, 10);
1702
+ return isDay(today) ? addDays(today, -back) : today;
1685
1703
  }
1686
1704
 
1687
1705
  /** Every row of one name whose CALENDAR date is on or after `from`. */
@@ -1901,7 +1919,7 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1901
1919
  `this store is on lived day ${String(report.livedDay)} — too new to grade; nothing has fired ` +
1902
1920
  `because nothing has happened yet` +
1903
1921
  (c.blocked === 0 ? "" : `, though ${String(c.blocked)} was already stopped by something`),
1904
- c.blocked === 0 ? "" : "Run: counterparts fired — the blocked rows say by what.",
1922
+ c.blocked === 0 ? "" : "Run: counterparts mechanisms --all — the blocked rows say by what.",
1905
1923
  data,
1906
1924
  ),
1907
1925
  ];
@@ -1938,8 +1956,8 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1938
1956
  "Fired",
1939
1957
  `${roll}. ${changed.join(". ")}`,
1940
1958
  report.wentBlocked.length > 0
1941
- ? `Run: counterparts fired — ${STATE_MEANING.blocked}, and the reason on the row names what to fix.`
1942
- : `Run: counterparts fired — ${STATE_MEANING.quiet}, which is a wiring fault more often than a verdict.`,
1959
+ ? `Run: counterparts mechanisms --all — ${STATE_MEANING.blocked}, and the reason on the row names what to fix.`
1960
+ : `Run: counterparts mechanisms --all — ${STATE_MEANING.quiet}, which is a wiring fault more often than a verdict.`,
1943
1961
  data,
1944
1962
  ),
1945
1963
  ];
@@ -2354,7 +2372,7 @@ export function selfPageFindings(store: Store): Finding[] {
2354
2372
  ),
2355
2373
  ];
2356
2374
  }
2357
- const stale = pageStaleOn(page.revisedOn, dateOf(store.now()), SELF_TUNABLES.PAGE_STALE_DAYS);
2375
+ const stale = pageStaleOn(page.revisedOn, store.today(), SELF_TUNABLES.PAGE_STALE_DAYS);
2358
2376
  const detail =
2359
2377
  `${page.bytes} bytes, version ${page.version}, last revised ${page.revisedOn === "" ? "(unrecorded)" : page.revisedOn}` +
2360
2378
  `${page.by === null ? "" : ` by ${page.by}`}`;
@@ -2493,7 +2511,7 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
2493
2511
  "Page writer",
2494
2512
  detail,
2495
2513
  bad || overdue
2496
- ? "counterparts fired --dir <store> --observer shows the run's own row. A night that is owed but never delivered is usually the host's injection ceiling: the block is deferred rather than truncated, so raise injectionBudgetBytes or run the writer in host mode. counterparts self-page --write amends the page by hand meanwhile."
2514
+ ? "counterparts mechanisms --all --dir <store> --observer shows the run's own row. A night that is owed but never delivered is usually the host's injection ceiling: the block is deferred rather than truncated, so raise injectionBudgetBytes or run the writer in host mode. counterparts self-page --write amends the page by hand meanwhile."
2497
2515
  : "",
2498
2516
  {
2499
2517
  ...data,
@@ -2980,6 +2998,7 @@ export function summaryLine(t: Record<Lowercase<GradeWord>, number>): string {
2980
2998
  * I32's own signature.
2981
2999
  */
2982
3000
  export function doctorFindings(input: DoctorInput): Finding[] {
3001
+ readingZone = resolveZone(input.config.timeZone);
2983
3002
  const now = input.now ?? ((): number => Date.now());
2984
3003
  const deadline = input.budgetMs === undefined ? null : now() + input.budgetMs;
2985
3004
  const unread = input.configReason === "not-read";
@@ -3249,7 +3268,7 @@ const TITLE_COLUMN = 20;
3249
3268
  * not green. */
3250
3269
  export function reportLines(findings: readonly Finding[], today: string): string[] {
3251
3270
  const ordered = worstFirst(findings);
3252
- const lines = [`counterparts doctor — ${today} (UTC)`, ""];
3271
+ const lines = [`counterparts doctor — ${today}`, ""];
3253
3272
  for (const f of ordered) lines.push(...findingLines(f));
3254
3273
  lines.push("");
3255
3274
  lines.push(summaryLine(tally(ordered)));
@@ -98,6 +98,7 @@ import {
98
98
  writerInstruction,
99
99
  writerInstructionOverhead,
100
100
  } from "../../core/self/index.js";
101
+ import { localClock, localDate } from "../../core/time.js";
101
102
  import { capabilities, pageWriterMode } from "./config.js";
102
103
  import { TUNABLES } from "./config.js";
103
104
  import type { AdapterConfig, CapabilityReport } from "./config.js";
@@ -690,10 +691,19 @@ export class ClaudeCodeAdapter {
690
691
  // running (mechanism inventory 2026-09-17, S2).
691
692
  this.noteWakeExpectation(input, woke.sentinel);
692
693
 
693
- if (budget !== undefined && woke.bytes > budget) {
694
+ // THE PERSON'S CLOCK, as the wake's first line (docs/time.md rule 5,
695
+ // 2026-09-25): `Now: Fri 25 Sep 2026, 1:40 pm MDT`, in the store's zone.
696
+ // OUTSIDE the wake block, above its opening comment, so the block's own
697
+ // byte count, both sentinels and the preface's reserve are untouched —
698
+ // the delivery check finds its sentinels by prefix, not by line number.
699
+ // It is counted wherever the host's ceiling is: the over-budget event
700
+ // and the room an ask may take both measure `sent`, not `woke.bytes`.
701
+ const lead = woke.text.length === 0 ? "" : `${this.nowLine()}\n`;
702
+ const sent = woke.bytes + Buffer.byteLength(lead, "utf8");
703
+ if (budget !== undefined && sent > budget) {
694
704
  // Exceeding a reported limit is an EVENT, never silent degradation. The
695
705
  // bundle still goes: truncated-and-detectable beats absent.
696
- this.emit("adapter.injection.overbudget", { bytes: woke.bytes, budget });
706
+ this.emit("adapter.injection.overbudget", { bytes: sent, budget });
697
707
  }
698
708
  this.record(WAKE_INJECTED_EVENT, input, {
699
709
  ok: woke.ok,
@@ -738,22 +748,22 @@ export class ClaudeCodeAdapter {
738
748
  // question is advisory and returns at the next session; a night that
739
749
  // passes is a day missing from the page for good (S2 review, MINOR-5).
740
750
  const scopeFirst = wantsAsk && !this.writerStarvedByScope();
741
- const ask = scopeFirst ? this.deliverScopeAsk(input, woke.bytes, budget) : "";
751
+ const ask = scopeFirst ? this.deliverScopeAsk(input, sent, budget) : "";
742
752
  const chosen =
743
- ask.length > 0 ? ask : this.deliverPageWriterAsk(input, woke.bytes, budget, false);
744
- if (ask.length > 0) this.deliverPageWriterAsk(input, woke.bytes, budget, true);
753
+ ask.length > 0 ? ask : this.deliverPageWriterAsk(input, sent, budget, false);
754
+ if (ask.length > 0) this.deliverPageWriterAsk(input, sent, budget, true);
745
755
  // THE WRITE-UP POINTER RIDES AFTER WHICHEVER ASK TOOK THE FIELD, never
746
756
  // instead of it (C2): it may coincide with either, it is measured against
747
757
  // the room BOTH of them left, and it is fail-open by construction — a
748
758
  // throw inside it costs the pointer and never the wake or the other ask.
749
759
  const chosenBytes = chosen.length === 0 ? 0 : Buffer.byteLength(`\n\n${chosen}`, "utf8");
750
- const writeUp = this.deliverWriteUpAsk(input, woke.bytes + chosenBytes);
760
+ const writeUp = this.deliverWriteUpAsk(input, sent + chosenBytes);
751
761
  const asks = [chosen, writeUp].filter((a) => a.length > 0).join("\n\n");
752
762
  return {
753
763
  ...out,
754
764
  ok: woke.ok,
755
765
  reason: woke.reason,
756
- injection: woke.text,
766
+ injection: `${lead}${woke.text}`,
757
767
  bytes: woke.bytes,
758
768
  sentinel: woke.sentinel,
759
769
  ask: asks.length === 0 ? null : asks,
@@ -1112,7 +1122,7 @@ export class ClaudeCodeAdapter {
1112
1122
  const text = writeUpPointer({
1113
1123
  waiting: owed.length,
1114
1124
  ended: held.session,
1115
- endedOn: calendarDate(held.clockFrom),
1125
+ endedOn: calendarDate(held.clockFrom, this.counterpart.store.zone()),
1116
1126
  bytes: cut.slice(done).reduce((n, p) => n + Buffer.byteLength(p, "utf8"), 0),
1117
1127
  part: Math.min(done + 1, partsCount),
1118
1128
  of: partsCount,
@@ -1200,7 +1210,7 @@ export class ClaudeCodeAdapter {
1200
1210
  this.checkWakeArrival(input);
1201
1211
  const text = input.prompt ?? "";
1202
1212
  if (text.trim().length === 0) {
1203
- return { ...out, ok: true, reason: "empty-prompt" };
1213
+ return { ...out, ok: true, reason: "empty-prompt", injection: this.nowLine() };
1204
1214
  }
1205
1215
  const result = this.counterpart.recallForTurn(
1206
1216
  {
@@ -1236,7 +1246,12 @@ export class ClaudeCodeAdapter {
1236
1246
  ...out,
1237
1247
  ok: true,
1238
1248
  reason: decision.reason,
1239
- injection: result.injection,
1249
+ // The current local time, EVERY turn (docs/time.md rule 5; the owner
1250
+ // asked for it on quiet turns too, 2026-09-25 — ~40 bytes), because a
1251
+ // session can run for hours. One line ABOVE the recall note when there
1252
+ // is one, outside it like the wake's, so the note's byte count and
1253
+ // sentinel stand; alone when recall surfaced nothing.
1254
+ injection: result.injection.length === 0 ? this.nowLine() : `${this.nowLine()}\n${result.injection}`,
1240
1255
  bytes: decision.bytes,
1241
1256
  sentinel: decision.sentinel,
1242
1257
  // The footnote tier is carried SEPARATELY from the loud one, because the
@@ -1247,6 +1262,11 @@ export class ClaudeCodeAdapter {
1247
1262
  });
1248
1263
  }
1249
1264
 
1265
+ /** `Now: Fri 25 Sep 2026, 1:40 pm MDT` — this adapter's clock, in the store's zone. */
1266
+ private nowLine(): string {
1267
+ return `Now: ${localClock(this.nowFn(), this.counterpart.store.zone())}`;
1268
+ }
1269
+
1250
1270
  /**
1251
1271
  * "COUNTERPARTS WAS UPDATED" — the line this session's terminal gets, once,
1252
1272
  * when the MCP server it is talking to runs an older build than the one
@@ -2118,7 +2138,7 @@ export class ClaudeCodeAdapter {
2118
2138
  */
2119
2139
  private noteSpawnStart(input?: HookInput): void {
2120
2140
  if (this.observer) return;
2121
- const date = input?.at ?? new Date(this.nowFn()).toISOString().slice(0, 10);
2141
+ const date = input?.at ?? localDate(this.nowFn(), this.counterpart.store.zone());
2122
2142
  try {
2123
2143
  this.bumpStart(date);
2124
2144
  this.counterpart.noteAdapterEvent(
@@ -2254,7 +2274,7 @@ export class ClaudeCodeAdapter {
2254
2274
  ): string | null {
2255
2275
  if (this.observer) return null;
2256
2276
  try {
2257
- const today = input.at ?? new Date(this.nowFn()).toISOString().slice(0, 10);
2277
+ const today = input.at ?? localDate(this.nowFn(), this.counterpart.store.zone());
2258
2278
  // WHICH CODE IS LIVE, read before anything else and RECORDED. The reading
2259
2279
  // is bounded and never throws (`readCheckout`); the row is the mechanized
2260
2280
  // half — a day on master leaves one latched row, and a day the tree
@@ -165,6 +165,7 @@ export function openAdapter(
165
165
  : { budgetBytes: config.injectionBudgetBytes }),
166
166
  ...(config.observer === undefined ? {} : { observer: config.observer }),
167
167
  ...(config.owner === undefined ? {} : { owner: config.owner }),
168
+ ...(config.timeZone === undefined ? {} : { timeZone: config.timeZone }),
168
169
  ...(config.identity === undefined
169
170
  ? {}
170
171
  : { identity: { name: config.identity.name, aliases: [...(config.identity.aliases ?? [])] } }),