@oathe/oathe 0.4.4 → 0.4.6

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 (59) hide show
  1. package/.claude-plugin/marketplace.json +18 -2
  2. package/README.md +6 -3
  3. package/bin/oathe.mjs +199 -35
  4. package/docs/PRIVACY.md +26 -4
  5. package/notch/Oathe Notch.app/Contents/Info.plist +1 -1
  6. package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
  7. package/notch/README.md +4 -3
  8. package/package.json +5 -4
  9. package/plugin/.claude-plugin/plugin.json +21 -3
  10. package/plugin/.cursor-plugin/plugin.json +2 -2
  11. package/plugin/hooks/hooks.json +4 -4
  12. package/plugin/hooks/lib.mjs +9 -0
  13. package/plugin/hooks/render-board.mjs +4 -2
  14. package/src/blocks.mjs +10 -1
  15. package/src/board-render.mjs +7 -4
  16. package/src/breach-digest.mjs +75 -10
  17. package/src/config.mjs +18 -0
  18. package/src/context.mjs +1 -1
  19. package/src/device.mjs +106 -0
  20. package/src/doctor.mjs +101 -6
  21. package/src/engine-update.mjs +170 -0
  22. package/src/evidence-discovery.mjs +170 -0
  23. package/src/fence.mjs +3 -3
  24. package/src/harnesses/catalog.mjs +46 -4
  25. package/src/harnesses/claude.mjs +56 -4
  26. package/src/harnesses/codex-rollout.mjs +110 -21
  27. package/src/harnesses/codex.mjs +106 -19
  28. package/src/harnesses/cursor.mjs +31 -18
  29. package/src/harnesses/harness.mjs +82 -13
  30. package/src/harnesses/surfaces.mjs +2 -2
  31. package/src/home.mjs +174 -52
  32. package/src/init.mjs +27 -2
  33. package/src/launch.mjs +7 -9
  34. package/src/launchd.mjs +100 -0
  35. package/src/manifest.mjs +48 -6
  36. package/src/mcp/connection.mjs +73 -7
  37. package/src/mcp/daemon.mjs +123 -0
  38. package/src/mcp/forwarder.mjs +99 -0
  39. package/src/mcp/oathe-tools.mjs +392 -145
  40. package/src/notch-frame.mjs +118 -42
  41. package/src/notch.mjs +34 -68
  42. package/src/oathe-annotator.mjs +10 -10
  43. package/src/pager.mjs +144 -40
  44. package/src/paths.mjs +1 -0
  45. package/src/plans.mjs +44 -5
  46. package/src/registry.mjs +10 -2
  47. package/src/serve.mjs +82 -0
  48. package/src/session-host.mjs +1 -1
  49. package/src/sessions.mjs +39 -8
  50. package/src/shim.mjs +110 -0
  51. package/src/speaker.mjs +24 -5
  52. package/src/statements.mjs +116 -2
  53. package/src/traces.mjs +61 -19
  54. package/src/uninstall.mjs +20 -3
  55. package/src/update.mjs +35 -7
  56. package/src/verifier.mjs +215 -105
  57. package/src/verify-dispatch.mjs +86 -32
  58. package/src/wire.mjs +7 -1
  59. package/plugin/.mcp.json +0 -10
@@ -1,10 +1,28 @@
1
1
  {
2
2
  "name": "oathe",
3
3
  "displayName": "Oathe",
4
- "version": "0.4.4",
4
+ "version": "0.4.6",
5
5
  "description": "Claims are speech acts: your session opens on this folder's board, records progress as statements, and yields what it cannot finish. Horizons move only by deliberate acts — never by session liveness.",
6
6
  "author": {
7
- "name": "Oathe"
7
+ "name": "Oathe",
8
+ "url": "https://oathe.ai"
8
9
  },
9
- "license": "Apache-2.0"
10
+ "homepage": "https://oathe.ai",
11
+ "repository": "https://github.com/oathe-ai/oathe",
12
+ "license": "Apache-2.0",
13
+ "keywords": [
14
+ "claude-code",
15
+ "agents",
16
+ "multi-agent",
17
+ "verification",
18
+ "settlement",
19
+ "handoff",
20
+ "reliability",
21
+ "harness",
22
+ "codex",
23
+ "cursor",
24
+ "durable-execution",
25
+ "accountability",
26
+ "auto-save"
27
+ ]
10
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oathe",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Claims are speech acts: your session opens on this folder's board, records progress as statements, and yields what it cannot finish. Horizons move only by deliberate acts — never by session liveness.",
5
5
  "author": {
6
6
  "name": "Oathe"
@@ -8,7 +8,7 @@
8
8
  "license": "Apache-2.0",
9
9
  "mcpServers": {
10
10
  "oathe": {
11
- "command": "oathe",
11
+ "command": "${userHome}/.oathe/bin/oathe",
12
12
  "args": [
13
13
  "mcp"
14
14
  ]
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Oathe session lifecycle: the board at SessionStart, lease heartbeat at Stop, frame note before compaction. Same three events exist verbatim in Claude Code and Codex. Commands go through the oathe bin on PATH \u2014 the plugin is cached by copy in Claude Code and Codex, so the tree carries no paths.",
2
+ "description": "Oathe session lifecycle: the board at SessionStart, lease heartbeat at Stop, frame note before compaction. Same three events exist verbatim in Claude Code and Codex. Commands go through the shim `oathe init` materializes at $HOME/.oathe/bin/oathe — the plugin is cached by copy, so the tree carries no machine paths, and shell-form commands expand $HOME where a GUI session's bare PATH would find no bin at all.",
3
3
  "hooks": {
4
4
  "SessionStart": [
5
5
  {
@@ -7,7 +7,7 @@
7
7
  "hooks": [
8
8
  {
9
9
  "type": "command",
10
- "command": "oathe hook render-board",
10
+ "command": "\"$HOME/.oathe/bin/oathe\" hook render-board",
11
11
  "timeout": 8
12
12
  }
13
13
  ]
@@ -18,7 +18,7 @@
18
18
  "hooks": [
19
19
  {
20
20
  "type": "command",
21
- "command": "oathe hook heartbeat",
21
+ "command": "\"$HOME/.oathe/bin/oathe\" hook heartbeat",
22
22
  "timeout": 5
23
23
  }
24
24
  ]
@@ -29,7 +29,7 @@
29
29
  "hooks": [
30
30
  {
31
31
  "type": "command",
32
- "command": "oathe hook frame-note",
32
+ "command": "\"$HOME/.oathe/bin/oathe\" hook frame-note",
33
33
  "timeout": 5
34
34
  }
35
35
  ]
@@ -39,6 +39,11 @@ export async function readHookInput() {
39
39
  return input;
40
40
  }
41
41
 
42
+ /** The one sentence a session-less hook speaks — on stderr for the person, in the session
43
+ * context for the model (ruling 2026-09-04: fail loud so the model does the right thing). */
44
+ export const UNATTRIBUTED_SESSION = 'this session cannot be attributed (the harness sent no session_id: no '
45
+ + 'registration, no trace link) — its claims will be refused; run `oathe init` and start a new session';
46
+
42
47
  export async function buildHookContext(input, env = process.env) {
43
48
  const paths = buildPaths(env);
44
49
  const dialect = dialectFor(input) ?? cwdDialect;
@@ -62,6 +67,10 @@ export async function buildHookContext(input, env = process.env) {
62
67
  harness: ownerOfTracePath(normalized.transcriptPath ?? ''),
63
68
  }
64
69
  : null;
70
+ // Session-lessness is reported, never swallowed (fail-soft still reports visibly): a
71
+ // desktop payload with no session_id left claims traceless and verification judging an
72
+ // empty record — silently, until 2026-09-04. One line, both lifecycle hooks ride it.
73
+ if (!session) process.stderr.write(`oathe hook: payload carries no session_id — ${UNATTRIBUTED_SESSION}\n`);
65
74
  return {
66
75
  session,
67
76
  substrate: new Substrate({ database: config.get('db'), paths, env, config }),
@@ -5,7 +5,7 @@
5
5
  // session's own dialect. Activation failing must never cost the session its board: the
6
6
  // failure is reported on stderr and the render proceeds (hooks are the sanctioned fail-soft).
7
7
 
8
- import { failSoft, emitSessionStart, ensureSessionRegistered } from './lib.mjs';
8
+ import { failSoft, emitSessionStart, ensureSessionRegistered, UNATTRIBUTED_SESSION } from './lib.mjs';
9
9
  import { renderBoard } from '../../src/board-render.mjs';
10
10
  import { WorkspaceRegistry } from '../../src/registry.mjs';
11
11
 
@@ -44,7 +44,9 @@ await failSoft(async ({ substrate, workspace, synthetic, identity, config, cwd,
44
44
  // (a receipt, printed once) even when the board itself has nothing to push.
45
45
  const visible = [message, disclosed].filter(Boolean).join('\n') || null;
46
46
  emitSessionStart({
47
- context: disclosed ? `${context}\n\n_${disclosed}_` : context,
47
+ // The model reads the disclosure and, when there is no session, the reason its claims
48
+ // will be refused — before it speaks (ruling 2026-09-04).
49
+ context: [context, disclosed ? `_${disclosed}_` : null, session ? null : `_Oathe: ${UNATTRIBUTED_SESSION}._`].filter(Boolean).join('\n\n'),
48
50
  message: visible,
49
51
  dialect,
50
52
  });
package/src/blocks.mjs CHANGED
@@ -227,7 +227,16 @@ export class JsonArrayEntries {
227
227
  }
228
228
  const leaf = path.at(-1);
229
229
  if (!Array.isArray(node[leaf])) node[leaf] = [];
230
- if (!node[leaf].some(owns)) node[leaf].push(element);
230
+ // Owned elements CONVERGE to the current shape (review F2, 2026-09-04): an entry a
231
+ // prior vintage wrote (an old address) is ours by the predicate and is REPLACED, and
232
+ // any further owned duplicates (the mixed-vintage state observed live) are pruned —
233
+ // push-if-absent alone left every re-wired machine running each hook twice, once
234
+ // through a dead path. User elements never match `owns` and are byte-preserved.
235
+ const owned = node[leaf].findIndex(owns);
236
+ if (owned === -1) node[leaf].push(element);
237
+ else node[leaf][owned] = element;
238
+ const keep = owned === -1 ? node[leaf].length - 1 : owned;
239
+ node[leaf] = node[leaf].filter((el, i) => i === keep || !owns(el));
231
240
  }
232
241
  const content = stringifyJsonTarget(doc);
233
242
  return { content, changed: content !== text };
@@ -14,7 +14,7 @@
14
14
 
15
15
  import { createOatheTools } from './mcp/oathe-tools.mjs';
16
16
  import { SPEECH_ACT_RULE } from './fence.mjs';
17
- import { BreachDigest, clip, rowLine, pullPointer } from './breach-digest.mjs';
17
+ import { BreachDigest, JUDGMENT, clip, rowLine, pullPointer } from './breach-digest.mjs';
18
18
 
19
19
  /** The board's scope, spoken once: the folder lens, or the whole machine (R-BOARD-SCOPE). */
20
20
  export const MACHINE_SCOPE_LABEL = 'all workspaces';
@@ -70,8 +70,8 @@ export async function renderBoard({ client, identity, workspace, config, synthet
70
70
  lines.push('');
71
71
  }
72
72
  if (asserted.length > 0) {
73
- lines.push('**Asserted (completion claimed — awaiting a non-author verdict; `oathe verify` runs it):**');
74
- for (const r of asserted) lines.push(`- [${r.task_id}] ${r.objective}`, ...spawned(r));
73
+ lines.push('**Asserted (completion claimed — a non-author verdict settles or reopens it; `oathe verify` runs it):**');
74
+ for (const r of asserted) lines.push(`- [${r.task_id}] ${r.objective} — ${judgmentWord(r)}`, ...spawned(r));
75
75
  lines.push('');
76
76
  }
77
77
  if (held.length > 0) {
@@ -92,6 +92,9 @@ export async function renderBoard({ client, identity, workspace, config, synthet
92
92
  return { context: lines.join('\n'), message: digest.push, sections, lens };
93
93
  }
94
94
 
95
+ /** The judgment an asserted row awaits, in the one table's words (UX rule 22). */
96
+ const judgmentWord = (r) => JUDGMENT[r.judgment]?.word ?? JUDGMENT.awaiting.word;
97
+
95
98
  const BOLD = '\x1b[1m';
96
99
  const DIM = '\x1b[2m';
97
100
  const RESET = '\x1b[0m';
@@ -128,7 +131,7 @@ export function renderSplash({ digest = null, sections, workspace }) {
128
131
  ? `last: ${r.last_progress.slice(0, 26)}`
129
132
  : `lease until ${r.lease_until}`));
130
133
  section('OPEN', open, (r) => (r.state === 'reopened' ? 'back — incomplete, actionable' : (r.state ?? 'unclaimed')));
131
- section('ASSERTED', asserted, () => 'awaiting verdict');
134
+ section('ASSERTED', asserted, judgmentWord);
132
135
  section('HELD', held, (r) => r.principal_id);
133
136
  section(`BREACHED PROMISES (${MACHINE_SCOPE_LABEL})`, digest.rows,
134
137
  (b) => `${b.kind_word}: ${rowLine(b)} · ${b.home}`, pullPointer('splash', digest.more));
@@ -14,6 +14,8 @@
14
14
  // Nothing about a kind is spelled twice: the glass reads the words off the frame, the
15
15
  // renderers read them off the rows.
16
16
 
17
+ import { Place } from './home.mjs';
18
+
17
19
  /** The resumption's word — a breach that continues into the work, and every working claim. */
18
20
  export const CONTINUE_ACT = 'continue ↗';
19
21
  export const KINDS = Object.freeze({
@@ -22,6 +24,35 @@ export const KINDS = Object.freeze({
22
24
  overdue: Object.freeze({ word: 'never verified', bucket: 'verify', act: 'verify ↗' }),
23
25
  quiet: Object.freeze({ word: 'quiet', bucket: 'quiet', act: CONTINUE_ACT }),
24
26
  });
27
+ /** The act a stall whose engine is out of date offers instead of retry (ruling 2026-09-05). */
28
+ export const UPDATE_ACT = 'update ↗';
29
+ /** The one sentence an open-app act shows on the row it expands (ruling 2026-09-05): the line is on the clipboard, the app's word is its adapter's. */
30
+ export const OPEN_APP_FLASH = (app) => `command copied — paste in ${app} to continue`;
31
+ /**
32
+ * The in-flight states ON a breach — ONE table (rulings 2026-09-04/05): a system claim is held,
33
+ * so the machine is doing the thing the row would otherwise ask for. `verify`: a judge holds
34
+ * `verify:<task>`. `update`: the machine holds `update:<engine>` and the row's stall names that
35
+ * engine as out of date. Either way the row says so, wears no failure, offers no act (the glass
36
+ * never offers an act it would refuse), and is not counted (nothing to act on). The pager stamps
37
+ * a row's `busy_word`/`busy_detail` from here; the digest and the glass render them and add nothing.
38
+ */
39
+ export const IN_FLIGHT = Object.freeze({
40
+ verify: Object.freeze({ word: 'verifying', detail: 'a verifier holds it — the verdict lands on the glass' }),
41
+ update: Object.freeze({
42
+ word: (name) => `updating ${name}`,
43
+ detail: (name) => `${name} is updating — the judgment re-runs when it lands`,
44
+ }),
45
+ });
46
+ /**
47
+ * The judgment an ASSERTED claim awaits (ruling 2026-09-04: nothing is invisible between done
48
+ * and verdict): `verifying` while a judge holds the verify claim — IN_FLIGHT.verify's word,
49
+ * spelled once, with the spinner — and `awaiting` until one does. Keyed by the board's
50
+ * `judgment`; every surface renders these words and adds nothing.
51
+ */
52
+ export const JUDGMENT = Object.freeze({
53
+ verifying: Object.freeze({ word: IN_FLIGHT.verify.word, busy: true }),
54
+ awaiting: Object.freeze({ word: 'awaiting verdict', busy: false }),
55
+ });
25
56
  /** The push buckets, in the order the one ambient line speaks them. */
26
57
  export const BUCKET_WORDS = Object.freeze({ fix: 'to fix', verify: 'to verify', quiet: 'gone quiet' });
27
58
  /** The kinds in sharpness order: a verdict that came back first, an unjudged assertion last. */
@@ -89,8 +120,23 @@ function pushLine(counts) {
89
120
  return parts.length > 0 ? parts.join(' · ') : null;
90
121
  }
91
122
 
123
+ /** A member's word: the kind's, unless its judgment is in flight. */
124
+ // A busy row wears the in-flight words the pager stamped (IN_FLIGHT); a busy row without them is
125
+ // not a row the pager made — refused, never defaulted (zero legacy, 2026-09-05).
126
+ const busyWords = (breach) => {
127
+ if (typeof breach.busy_word !== 'string' || typeof breach.busy_detail !== 'string') {
128
+ throw new DigestError('OATHE_DIGEST_BUSY_UNWORDED', `busy breach '${breach.task_id}' carries no busy_word/busy_detail — the pager stamps both`, { task_id: breach.task_id });
129
+ }
130
+ return { word: breach.busy_word, detail: breach.busy_detail };
131
+ };
132
+ const busyWord = (breach) => busyWords(breach).word;
133
+ const busyDetail = (breach) => busyWords(breach).detail;
134
+ const wordOf = (breach) => (breach.busy ? busyWord(breach) : KINDS[breach.kind].word);
135
+
92
136
  function single(breach) {
93
- return { ...breach, kind_word: KINDS[breach.kind].word, group: null };
137
+ return breach.busy
138
+ ? { ...breach, busy: true, kind_word: busyWord(breach), detail: busyDetail(breach), group: null }
139
+ : { ...breach, busy: false, kind_word: KINDS[breach.kind].word, group: null };
94
140
  }
95
141
 
96
142
  /**
@@ -103,25 +149,39 @@ function groupRow(own, children) {
103
149
  const members = [...(own ? [own] : []), ...children].sort(breachOrder);
104
150
  const sortedChildren = [...children].sort(breachOrder);
105
151
  const byKind = {};
106
- for (const child of children) byKind[child.kind] = (byKind[child.kind] ?? 0) + 1;
152
+ let busyChildren = 0;
153
+ for (const child of children) {
154
+ if (child.busy) busyChildren += 1;
155
+ else byKind[child.kind] = (byKind[child.kind] ?? 0) + 1;
156
+ }
107
157
  const shown = sortedChildren.slice(0, DIGEST_ROW_CAP);
108
158
  const more = children.length - shown.length;
109
159
  const lead = own ?? members[0];
110
160
  const detail = [
111
- ...(own ? [own.detail] : []),
112
- ...shown.map((child) => `${child.task_id} · ${KINDS[child.kind].word} · ${child.detail}`),
161
+ ...(own ? [own.busy ? busyDetail(own) : own.detail] : []),
162
+ ...shown.map((child) => `${child.task_id} · ${wordOf(child)} · ${child.busy ? busyDetail(child) : child.detail}`),
113
163
  ...(more > 0 ? [`+${more} more`] : []),
114
164
  ].join('\n');
165
+ // The one act a verify-led group offers targets its oldest child whose judgment is NOT in
166
+ // flight — a child being judged is not retried; none idle → the row offers no act.
167
+ const retry = sortedChildren.find((child) => !child.busy)?.task_id ?? null;
115
168
  return {
116
169
  kind: members[0].kind,
117
- kind_word: [...(own ? [KINDS[own.kind].word] : []), countWords(byKind)].join(' · '),
170
+ kind_word: [
171
+ ...(own ? [wordOf(own)] : []),
172
+ countWords(byKind),
173
+ ...(busyChildren > 0 ? [`${busyChildren} ${IN_FLIGHT.verify.word}`] : []),
174
+ ].filter(Boolean).join(' · '),
118
175
  task_id: own ? own.task_id : children[0].parent,
119
176
  objective: own ? own.objective : children[0].parent_objective,
120
177
  home: lead.home,
121
178
  home_ref: lead.home_ref,
179
+ place: lead.place ?? null,
180
+ places: lead.places ?? [],
122
181
  detail,
123
182
  at: members[0].at,
124
- group: { n: children.length, by_kind: byKind, children: shown.map((child) => child.task_id), more },
183
+ busy: own?.busy === true,
184
+ group: { n: children.length, by_kind: byKind, children: shown.map((child) => child.task_id), more, retry },
125
185
  };
126
186
  }
127
187
 
@@ -159,8 +219,10 @@ export class BreachDigest {
159
219
  }
160
220
  }
161
221
  this.#breaches = breaches;
222
+ // A judgment in flight is not a breach to act on: it keeps its row (a person sees it
223
+ // verifying) and leaves every count — the ambient line, attention, the model channel.
162
224
  this.counts = Object.fromEntries(BREACH_KINDS.map((kind) => [kind, 0]));
163
- for (const breach of breaches) this.counts[breach.kind] += 1;
225
+ for (const breach of breaches) if (!breach.busy) this.counts[breach.kind] += 1;
164
226
  this.total = breaches.length;
165
227
  this.push = pushLine(this.counts);
166
228
  const { rows, rowOf } = groupSiblings(breaches);
@@ -171,9 +233,12 @@ export class BreachDigest {
171
233
  }
172
234
 
173
235
  /** This board's digest — the facts homed on `homeRef`; `null` is the whole machine (this). */
174
- scoped(homeRef) {
175
- if (homeRef === null) return this;
176
- return new BreachDigest({ breaches: this.#breaches.filter((breach) => breach.home_ref === homeRef) });
236
+ scoped(workspaceRef) {
237
+ if (workspaceRef === null) return this;
238
+ // A breach belongs to EVERY folder that ever picked its task up (ruling 2026-09-05) — the
239
+ // row's `places` — never only to where it resides now.
240
+ const here = String(Place.workspace(workspaceRef));
241
+ return new BreachDigest({ breaches: this.#breaches.filter((breach) => (breach.places ?? []).includes(here)) });
177
242
  }
178
243
 
179
244
  /** The digest over the rows `keep` accepts — a group is kept or dropped whole. */
package/src/config.mjs CHANGED
@@ -80,6 +80,24 @@ const KEYS = Object.freeze({
80
80
  // every re-wired notch unloaded because the one attempt's refusal went unread).
81
81
  notchRestartSeconds: { default: 10, env: 'OATHE_NOTCH_RESTART_SECONDS', check: positiveInt },
82
82
  notchRestartPollMs: { default: 100, env: 'OATHE_NOTCH_RESTART_POLL_MS', check: positiveInt },
83
+ // The serve daemon (connection-lane phase 2): the unix socket the device's one oathe
84
+ // presence answers on — null derives <oathe home>/serve.sock (src/serve.mjs); a path
85
+ // overrides it. The connect budget is the forwarder's ONE attempt before it falls back to
86
+ // the standalone stdio server (a measured fact, never a hang); the restart budget is the
87
+ // same launchd lesson the notch keys carry.
88
+ serveSocket: { default: null, env: 'OATHE_SERVE_SOCKET', check: nullOrString },
89
+ serveConnectMs: { default: 250, env: 'OATHE_SERVE_CONNECT_MS', check: positiveInt },
90
+ serveRestartSeconds: { default: 10, env: 'OATHE_SERVE_RESTART_SECONDS', check: positiveInt },
91
+ serveRestartPollMs: { default: 100, env: 'OATHE_SERVE_RESTART_POLL_MS', check: positiveInt },
92
+ // The blocking exchange, declared to the transport (ruling 2026-09-05): `done`/`verify` wait
93
+ // for the verdict where the work is, so every MCP client that caps a tool call must be told
94
+ // the budget — each adapter writes it where its client reads it (mcpToolTimeout touchpoint).
95
+ // 900s: ~3× the longest verify measured on the founder's substrate (p50 80s, p90 177s, max
96
+ // 315s over 40 runs; codex's 60s default sat below the median), finite so a wedged engine
97
+ // surfaces as a client timeout, never an hour-long spinner. While it waits the server says
98
+ // "still judging" this often — a standard MCP progress notification on the call's token.
99
+ mcpToolTimeoutSec: { default: 900, env: 'OATHE_MCP_TOOL_TIMEOUT_SEC', check: positiveInt },
100
+ mcpProgressIntervalSec: { default: 15, env: 'OATHE_MCP_PROGRESS_INTERVAL_SEC', check: positiveInt },
83
101
  });
84
102
 
85
103
  function nonEmptyString(v) {
package/src/context.mjs CHANGED
@@ -20,7 +20,7 @@ export function buildContext({ env = process.env, exec, cwd = process.cwd() } =
20
20
  const home = homeOf(env);
21
21
  const config = new OatheConfig({ env, cwd });
22
22
  const manifest = InstallManifest.load({ manifestPath: paths.manifestPath, backupsDir: paths.backupsDir });
23
- const harnesses = buildAll({ home, envPath: env.PATH, paths, exec }); // the ONE roster; consumers filter by capability
23
+ const harnesses = buildAll({ home, envPath: env.PATH, paths, exec, config }); // the ONE roster; consumers filter by capability
24
24
  const substrate = new Substrate({ database: config.get('db'), paths, env, config });
25
25
  const identity = {
26
26
  orgId: config.get('org'),
package/src/device.mjs ADDED
@@ -0,0 +1,106 @@
1
+ // oathe — the device identity (founder ruling 2026-09-04): person → device → session. The
2
+ // person comes from auth at the cloud seam; the SESSION is attested on this machine by the
3
+ // daemon; the DEVICE is the trust unit anything outside this machine will sign against. So
4
+ // `oathe init` mints ONE identity under the oathe home — a random id and an ed25519 key pair,
5
+ // derived from no hardware, in a 0600 file — the way the shim is materialized (src/shim.mjs):
6
+ // an oathe-home-owned artifact with one manifest row the doctor verifies and uninstall removes.
7
+ // It is KEPT byte-for-byte on every re-init: re-minting would sever every prior act's device
8
+ // ref. A malformed file is a typed refusal, never silently replaced. No signer ships in this
9
+ // lane — the key is minted for enrollment, and the copy says exactly that.
10
+
11
+ import fs from 'node:fs';
12
+ import path from 'node:path';
13
+ import crypto from 'node:crypto';
14
+
15
+ import { sha256Hex } from './manifest.mjs';
16
+
17
+ export const DEVICE_FORMAT = 1;
18
+ const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
19
+
20
+ export class OatheDeviceError extends Error {
21
+ constructor(code, message, details = {}) {
22
+ super(message);
23
+ this.name = 'OatheDeviceError';
24
+ this.code = code;
25
+ this.details = details;
26
+ }
27
+ }
28
+
29
+ /** The identity on disk, whole — `null` when never minted; a broken file refuses typed. */
30
+ function readDevice(devicePath) {
31
+ if (!fs.existsSync(devicePath)) return null;
32
+ const raw = fs.readFileSync(devicePath, 'utf8');
33
+ let doc;
34
+ try {
35
+ doc = JSON.parse(raw);
36
+ } catch (e) {
37
+ throw new OatheDeviceError('OATHE_DEVICE_MALFORMED',
38
+ `${devicePath} is not JSON (${e.message}) — the device identity is never re-minted over a `
39
+ + 'broken file; move it aside and run `oathe init`', { file: devicePath });
40
+ }
41
+ if (doc?.format !== DEVICE_FORMAT || typeof doc.device_id !== 'string' || !UUID_V4.test(doc.device_id)) {
42
+ throw new OatheDeviceError('OATHE_DEVICE_MALFORMED',
43
+ `${devicePath} carries no device_id in format ${DEVICE_FORMAT} — the device identity is never `
44
+ + 're-minted over a broken file; move it aside and run `oathe init`', { file: devicePath });
45
+ }
46
+ return { doc, raw };
47
+ }
48
+
49
+ /** The device id — `null` when no identity was minted (never invented at read time). */
50
+ export function readDeviceId({ devicePath }) {
51
+ return readDevice(devicePath)?.doc.device_id ?? null;
52
+ }
53
+
54
+ /**
55
+ * Mint the identity once, keep it forever, record it as ONE manifest row.
56
+ * @returns {[{action: 'device-minted'|'device-kept', file: string, device_id: string}]}
57
+ */
58
+ export function writeDevice({ devicePath, manifest, version, clock = () => new Date() }) {
59
+ const existing = readDevice(devicePath);
60
+ let raw = existing?.raw;
61
+ let deviceId = existing?.doc.device_id;
62
+ if (!existing) {
63
+ const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');
64
+ deviceId = crypto.randomUUID();
65
+ raw = `${JSON.stringify({
66
+ format: DEVICE_FORMAT,
67
+ device_id: deviceId,
68
+ key: {
69
+ alg: 'ed25519',
70
+ public_pem: publicKey.export({ type: 'spki', format: 'pem' }),
71
+ private_pem: privateKey.export({ type: 'pkcs8', format: 'pem' }),
72
+ },
73
+ minted_at: clock().toISOString(),
74
+ }, null, 2)}\n`;
75
+ // Temp-then-rename with the mode on the temp write, then chmod after the rename: rename
76
+ // keeps a pre-existing file's mode (the shim's precedent, src/shim.mjs).
77
+ fs.mkdirSync(path.dirname(devicePath), { recursive: true });
78
+ const tmp = `${devicePath}.tmp-${process.pid}`;
79
+ fs.writeFileSync(tmp, raw, { mode: 0o600 });
80
+ fs.renameSync(tmp, devicePath);
81
+ }
82
+ fs.chmodSync(devicePath, 0o600);
83
+ // One device, ONE row (the shim's F1 lesson): a re-run replaces, never accumulates.
84
+ manifest.removeWhere((r) => r.kind === 'device-id');
85
+ manifest.upsert({
86
+ harness: 'device',
87
+ file: devicePath,
88
+ kind: 'device-id',
89
+ detail: { device_id: deviceId },
90
+ blockVersion: version,
91
+ sha256: sha256Hex(raw),
92
+ });
93
+ return [{ action: existing ? 'device-kept' : 'device-minted', file: devicePath, device_id: deviceId }];
94
+ }
95
+
96
+ /** Remove exactly what was recorded; absence is a stated action, never silence. */
97
+ export function unwireDevice({ manifest }) {
98
+ const rows = manifest.removeWhere((r) => r.kind === 'device-id');
99
+ if (rows.length === 0) return [{ action: 'device-absent' }];
100
+ const actions = [];
101
+ for (const row of rows) {
102
+ fs.rmSync(row.file, { force: true });
103
+ actions.push({ action: 'device-removed', file: row.file });
104
+ }
105
+ return actions;
106
+ }
package/src/doctor.mjs CHANGED
@@ -8,8 +8,31 @@ import path from 'node:path';
8
8
  import { buildContext, packageVersion } from './context.mjs';
9
9
  import { FencedBlock, FENCE_STYLES, JsonEntries } from './blocks.mjs';
10
10
  import { sha256Hex } from './manifest.mjs';
11
+ import { spawnSync } from 'node:child_process';
11
12
  import { launchdJob } from './notch.mjs';
13
+ import { agentPathEnv } from './launchd.mjs';
14
+
15
+ /**
16
+ * A manifest the doctor cannot read is a broken install, said loudly (zero legacy, founder
17
+ * 2026-09-05): a row of a kind this tree does not know, or a row missing a field this tree's
18
+ * writer always records, is never a status line — the fix is named.
19
+ */
20
+ export class DoctorError extends Error {
21
+ constructor(code, message, details = {}) {
22
+ super(message);
23
+ this.name = 'DoctorError';
24
+ this.code = code;
25
+ this.details = details;
26
+ }
27
+ }
28
+
29
+ const REINSTALL = 'uninstall with the oathe that wrote it, then run oathe init';
30
+ function malformed(row, what) {
31
+ return new DoctorError('OATHE_MANIFEST_ROW_MALFORMED',
32
+ `manifest row ${row.kind} for ${row.file} carries no ${what} — not a row this oathe writes; ${REINSTALL}`, { row });
33
+ }
12
34
  import { defaultExec } from './harnesses/harness.mjs';
35
+ import { byName } from './harnesses/catalog.mjs';
13
36
 
14
37
  function verifyJsonRow(row) {
15
38
  if (!fs.existsSync(row.file)) return 'file-missing';
@@ -24,17 +47,40 @@ function verifyJsonRow(row) {
24
47
  return sha256Hex(JSON.stringify(entries)) === row.sha256 ? 'ok' : 'user-edited';
25
48
  }
26
49
 
50
+ /** The fence style every fence row records (fence.mjs); a row without one is not ours. */
51
+ export function fenceStyleOf(row) {
52
+ const style = FENCE_STYLES[row.detail?.style];
53
+ if (!style) throw malformed(row, 'known fence style');
54
+ return style;
55
+ }
56
+
27
57
  function verifyFenceRow(row) {
58
+ const block = new FencedBlock({ style: fenceStyleOf(row) }); // the row's shape first — a malformed row is malformed whatever the file does
28
59
  if (!fs.existsSync(row.file)) return 'file-missing';
29
- const block = new FencedBlock({ style: FENCE_STYLES[row.detail?.style ?? 'hash'] });
30
60
  const seen = block.read(fs.readFileSync(row.file, 'utf8'));
31
61
  if (!seen.present) return 'removed';
32
62
  return sha256Hex(seen.blockText) === row.sha256 ? 'ok' : 'user-edited';
33
63
  }
34
64
 
35
65
  function verifyCliRow(row) {
66
+ // Two sub-shapes, both written today: a parsed JSON entry (detail.command) or proof lines
67
+ // (detail.proofs). The row's shape is checked before the file — malformed is malformed.
68
+ const proofs = row.detail?.command !== undefined ? null : row.detail?.proofs;
69
+ if (proofs !== null && (!Array.isArray(proofs) || proofs.length === 0)) throw malformed(row, 'proofs');
36
70
  if (!fs.existsSync(row.file)) return 'file-missing';
37
- return fs.readFileSync(row.file, 'utf8').includes(row.detail?.proof) ? 'ok' : 'removed';
71
+ const text = fs.readFileSync(row.file, 'utf8');
72
+ // A JSON file the CLI owns (claude's ~/.claude.json): the proof is the PARSED entry — a
73
+ // substring cannot survive the CLI's own formatting. detail.command is the address the
74
+ // entry must carry; a different one is a drifted lane, visible on the machine it broke on.
75
+ if (row.detail?.command !== undefined) {
76
+ let entry;
77
+ try { entry = JSON.parse(text)?.mcpServers?.oathe ?? null; } catch { return 'user-edited'; }
78
+ if (entry === null) return 'removed';
79
+ return entry.command === row.detail.command ? 'ok' : 'user-edited';
80
+ }
81
+ // Every proof line must stand (the codex stanza carries the address AND the timeout budget the
82
+ // CLI's re-add drops).
83
+ return proofs.every((p) => text.includes(p)) ? 'ok' : 'removed';
38
84
  }
39
85
 
40
86
  function verifyJsonArrayRow(row) {
@@ -85,9 +131,28 @@ function verifyNotchAppRow(row) {
85
131
  return sha256Hex(fs.readFileSync(binary)) === row.sha256 ? 'ok' : 'user-edited';
86
132
  }
87
133
 
88
- const VERIFIERS = {
134
+ // A whole-file write (the shim, the device identity) is byte-identical to what init stamped,
135
+ // or user-edited; gone is gone — a gone shim means every harness's MCP entry points at
136
+ // nothing, a gone device means every act speaks from no device.
137
+ function verifyWholeFileRow(row) {
138
+ if (!fs.existsSync(row.file)) return 'file-missing';
139
+ return sha256Hex(fs.readFileSync(row.file, 'utf8')) === row.sha256 ? 'ok' : 'user-edited';
140
+ }
141
+
142
+ // A CLI's recorded address (ruling 2026-09-05: engines are addresses) is proved by the
143
+ // SUPERVISOR'S ANSWER, not a stat: `<address> <versionArgs>` runs under the LaunchAgent's PATH —
144
+ // the world the notch feed and the serve daemon spawn a judgment from — and exit 0 is ok. This
145
+ // catches what X_OK misses: a node-script CLI whose interpreter that PATH no longer names.
146
+ function verifyCliAddressRow(row, { probe }) {
147
+ if (!fs.existsSync(row.file)) return 'file-missing';
148
+ return probe(row.file, byName(row.harness).install.versionArgs).status === 0 ? 'ok' : 'unreachable';
149
+ }
150
+
151
+ /** Every manifest kind this tree writes, with its verifier — the machine surface (docs/PRODUCT.md §3). */
152
+ export const VERIFIERS = {
89
153
  'json-path': verifyJsonRow, fence: verifyFenceRow, 'cli-managed': verifyCliRow, 'json-array': verifyJsonArrayRow,
90
- 'launch-agent': verifyLaunchAgentRow, 'notch-app': verifyNotchAppRow,
154
+ 'launch-agent': verifyLaunchAgentRow, 'notch-app': verifyNotchAppRow, 'oathe-shim': verifyWholeFileRow,
155
+ 'device-id': verifyWholeFileRow, 'cli-address': verifyCliAddressRow,
91
156
  };
92
157
 
93
158
  /**
@@ -120,8 +185,18 @@ export async function runSurfaceReport({ env = process.env, cwd = () => process.
120
185
  }
121
186
 
122
187
  /** @returns {Promise<{rows: object[], substrate: object, plugin: {resolves: boolean, detail: string|null}}>} */
188
+ function verifierFor(row) {
189
+ const verify = VERIFIERS[row.kind];
190
+ if (!verify) {
191
+ throw new DoctorError('OATHE_MANIFEST_KIND_UNKNOWN',
192
+ `manifest row kind '${row.kind}' (${row.file}) is not one this oathe writes (${Object.keys(VERIFIERS).join(', ')}) — ${REINSTALL}`, { row });
193
+ }
194
+ return verify;
195
+ }
196
+
123
197
  export async function runDoctor({ env = process.env, exec = defaultExec } = {}) {
124
198
  const launchd = (label) => launchdJob({ label, exec });
199
+ const probe = (file, args) => spawnSync(file, args, { encoding: 'utf8', env: { ...env, PATH: agentPathEnv() }, timeout: 20_000 });
125
200
  const ctx = buildContext({ env });
126
201
  const { manifest, substrate, paths, harnesses } = ctx;
127
202
  try {
@@ -136,7 +211,7 @@ export async function runDoctor({ env = process.env, exec = defaultExec } = {})
136
211
  file: row.file,
137
212
  kind: row.kind,
138
213
  block_version: row.block_version,
139
- status: (VERIFIERS[row.kind] ?? (() => 'unknown-kind'))(row, { launchd }),
214
+ status: verifierFor(row)(row, { launchd, probe }),
140
215
  }));
141
216
  // The trace-contract monitor: both vendors disclaim transcript-schema stability, so the
142
217
  // doctor validates the NEWEST live record in each engine's store against docs/traces.md and
@@ -167,7 +242,11 @@ export async function runDoctor({ env = process.env, exec = defaultExec } = {})
167
242
  const fidelity = await fidelityOf({
168
243
  store, project: (file) => projectAnnotated(file, { home }), fidelity: capability.fidelity, files, traceStatus: traceStatusOf,
169
244
  });
245
+ // The staging gate (B1, 2026-09-06): the adapter says whether the newest rollout's writer ran
246
+ // from a dir it knows as staging — the day the desktop moves again, this line says so.
247
+ const stagingDrift = capability.stagingDrift?.(store.describe(newest), { home }) ?? null;
170
248
  const failures = [
249
+ ...(stagingDrift ? [stagingDrift] : []),
171
250
  ...census.undeclared.map((u) => `undeclared ${u.channel}.${u.type} ×${u.count} (first: ${u.example})`),
172
251
  ...fidelity.projectionErrors.filter((p) => p.status === 'DRIFT').map((p) => `${p.file}: ${p.detail}`),
173
252
  ...fidelity.probes.flatMap((p) => p.failed.map((f) => `${p.probe}: ${f.file}: ${f.detail}`)),
@@ -210,7 +289,23 @@ export async function runDoctor({ env = process.env, exec = defaultExec } = {})
210
289
  capabilities: null, error: String(e?.message || e), probe: null };
211
290
  }
212
291
 
213
- return { version, rows, substrate: await substrate.status(), plugin, traces, runtime };
292
+ // The daemon probe (phase 2): a REAL MCP initialize over the socket — the launch-agent
293
+ // row above says what launchd holds; this says whether an MCP server ANSWERS where the
294
+ // forwarders knock (a bare connect proves a listener, not a server — a wedged process
295
+ // squatting the socket must never read as ok; the verifier's catch, 2026-09-04).
296
+ let daemon;
297
+ try {
298
+ const [{ serveSocketPath }, { probeDaemon }] = await Promise.all([
299
+ import('./serve.mjs'), import('./mcp/forwarder.mjs'),
300
+ ]);
301
+ const socket = serveSocketPath(paths, ctx.config);
302
+ const probe = await probeDaemon({ socketPath: socket, timeoutMs: ctx.config.get('serveConnectMs') });
303
+ daemon = { socket, answering: probe.answering, server: probe.server };
304
+ } catch (e) {
305
+ daemon = { socket: null, answering: false, server: null, detail: String(e?.message || e) };
306
+ }
307
+
308
+ return { version, rows, substrate: await substrate.status(), plugin, traces, runtime, daemon };
214
309
  } finally {
215
310
  await substrate.close();
216
311
  }