@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
@@ -11,8 +11,8 @@ import fs from 'node:fs';
11
11
  import path from 'node:path';
12
12
  import { spawn as nodeSpawn } from 'node:child_process';
13
13
 
14
- import { isVerificationTask, verificationTaskId } from './plans.mjs';
15
- import { isEngineFailureSql } from './statements.mjs';
14
+ import { isVerificationTask, verificationTaskId, verifiedTaskId, updateTaskId } from './plans.mjs';
15
+ import { isVerifyStallSql } from './statements.mjs';
16
16
  import { pidAlive } from './sessions.mjs';
17
17
 
18
18
  export class VerifyDispatchError extends Error {
@@ -42,49 +42,65 @@ function scrubbedEnv(env) {
42
42
  * @returns {Promise<{started: true, task_id: string, verification_task: string, engine: string|null,
43
43
  * pid: number, log: string, note: string}>}
44
44
  */
45
- export async function dispatchVerification({
46
- taskId, engine = null, orgId, query, paths, cwd, env, spawn = nodeSpawn, clock = () => new Date(),
47
- }) {
48
- const verificationTask = isVerificationTask(taskId) ? taskId : verificationTaskId(taskId);
49
- const originalTask = verificationTask.slice('verify:'.length);
50
-
45
+ /**
46
+ * A system task already HELD refuses a second dispatch — the row already says what is running.
47
+ * @param {{what: string}} o what — the act in words ("a verification of 'x'", "an update of 'codex'")
48
+ */
49
+ async function refuseIfHeld({ query, orgId, taskId, clock, code, what }) {
51
50
  const { rows } = await query(
52
51
  `SELECT principal_id, state, ownership_valid_until
53
52
  FROM cell.work_claim WHERE org_id = $1 AND task_id = $2
54
- ORDER BY claimed_at DESC LIMIT 1`, [orgId, verificationTask]);
53
+ ORDER BY claimed_at DESC LIMIT 1`, [orgId, taskId]);
55
54
  const latest = rows[0];
56
- if (latest?.state === 'active') {
57
- const until = latest.ownership_valid_until ? new Date(latest.ownership_valid_until) : null;
58
- const expired = until !== null && until < clock();
59
- throw new VerifyDispatchError('OATHE_VERIFY_IN_FLIGHT',
60
- expired
61
- ? `a verification of '${originalTask}' is still claimed by ${latest.principal_id} but its `
62
- + `lease expired ${until.toISOString()} — likely a dead run; \`oathe yield ${verificationTask}\` `
63
- + 'releases it, then dispatch again'
64
- : `a verification of '${originalTask}' is already running — claimed by ${latest.principal_id}`
65
- + `${until ? ` until ${until.toISOString()}` : ''}; its verdict lands on the board`,
66
- { verification_task: verificationTask, holder: latest.principal_id, expired });
67
- }
55
+ if (latest?.state !== 'active') return;
56
+ const until = latest.ownership_valid_until ? new Date(latest.ownership_valid_until) : null;
57
+ const expired = until !== null && until < clock();
58
+ throw new VerifyDispatchError(code,
59
+ expired
60
+ ? `${what} is still claimed by ${latest.principal_id} but its `
61
+ + `lease expired ${until.toISOString()} — likely a dead run; \`oathe yield ${taskId}\` `
62
+ + 'releases it, then dispatch again'
63
+ : `${what} is already running — claimed by ${latest.principal_id}`
64
+ + `${until ? ` until ${until.toISOString()}` : ''}; its outcome lands on the board`,
65
+ { system_task: taskId, verification_task: taskId, holder: latest.principal_id, expired });
66
+ }
68
67
 
68
+ /**
69
+ * The ONE detached spawn of a bin verb: own process group (it outlives the session, the feed,
70
+ * the daemon), a log under logsDir overwritten per run (no retention machinery), a scrubbed env.
71
+ * @returns {{pid: number, log: string}}
72
+ */
73
+ function spawnDetachedVerb({ paths, args, cwd, env, logName, spawn }) {
69
74
  fs.mkdirSync(paths.logsDir, { recursive: true });
70
- const log = path.join(paths.logsDir, `verify-${originalTask.replace(/[^A-Za-z0-9._-]+/g, '-')}.log`);
71
- const logFd = fs.openSync(log, 'w'); // one log per task, overwritten per run — no retention machinery
75
+ const log = path.join(paths.logsDir, `${logName.replace(/[^A-Za-z0-9._-]+/g, '-')}.log`);
76
+ const logFd = fs.openSync(log, 'w');
72
77
  let child;
73
78
  try {
74
- child = spawn(process.execPath,
75
- [path.join(paths.packageRoot, 'bin/oathe.mjs'), 'verify', originalTask, ...(engine ? ['--engine', engine] : [])],
79
+ child = spawn(process.execPath, [path.join(paths.packageRoot, 'bin/oathe.mjs'), ...args],
76
80
  { detached: true, cwd, env: scrubbedEnv(env), stdio: ['ignore', logFd, logFd] });
77
81
  } finally {
78
82
  fs.closeSync(logFd); // the child holds its own copy; the long-lived server must not leak one per dispatch
79
83
  }
80
84
  child.unref();
85
+ return { pid: child.pid, log };
86
+ }
81
87
 
88
+ export async function dispatchVerification({
89
+ taskId, engine = null, orgId, query, paths, cwd, env, spawn = nodeSpawn, clock = () => new Date(),
90
+ }) {
91
+ const verificationTask = isVerificationTask(taskId) ? taskId : verificationTaskId(taskId);
92
+ const originalTask = verifiedTaskId(verificationTask);
93
+ await refuseIfHeld({ query, orgId, taskId: verificationTask, clock, code: 'OATHE_VERIFY_IN_FLIGHT', what: `a verification of '${originalTask}'` });
94
+ const { pid, log } = spawnDetachedVerb({
95
+ paths, cwd, env, spawn, logName: `verify-${originalTask}`,
96
+ args: ['verify', originalTask, ...(engine ? ['--engine', engine] : [])],
97
+ });
82
98
  return {
83
99
  started: true,
84
100
  task_id: originalTask,
85
101
  verification_task: verificationTask,
86
102
  engine,
87
- pid: child.pid,
103
+ pid,
88
104
  log,
89
105
  note: `verification of '${originalTask}' started in the background as ${verificationTask} — `
90
106
  + 'when it leaves the board the claim settled; a rejection reopens the task with the reason '
@@ -92,23 +108,52 @@ export async function dispatchVerification({
92
108
  };
93
109
  }
94
110
 
111
+ /**
112
+ * The glass's `update ↗` (ruling 2026-09-05): `oathe engine update <harness> --then-verify`
113
+ * detached through the same spawn as a judgment. The child CLAIMS `update:<harness>`, so the
114
+ * next frame reads "updating <Harness>" off the substrate — this process remembers nothing.
115
+ * @returns {Promise<{started: true, harness: string, update_task: string, pid: number, log: string, note: string}>}
116
+ */
117
+ export async function dispatchEngineUpdate({ harness, orgId, query, paths, cwd, env, spawn = nodeSpawn, clock = () => new Date() }) {
118
+ const updateTask = updateTaskId(harness);
119
+ await refuseIfHeld({ query, orgId, taskId: updateTask, clock, code: 'OATHE_UPDATE_IN_FLIGHT', what: `an update of '${harness}'` });
120
+ const { pid, log } = spawnDetachedVerb({
121
+ paths, cwd, env, spawn, logName: `update-${harness}`, args: ['engine', 'update', harness, '--then-verify'],
122
+ });
123
+ return {
124
+ started: true, harness, update_task: updateTask, pid, log,
125
+ note: `updating ${harness} in the background as ${updateTask} — when it leaves the board the CLI updated `
126
+ + `and every judgment its old version failed re-runs; a failure lands on ${updateTask}'s record. Log: ${log}`,
127
+ };
128
+ }
129
+
95
130
  /**
96
131
  * AWAIT a dispatched judgment's outcome from the substrate — the blocking half of the
97
132
  * local rule. The engine still runs in its own detached process; this only reads. The
98
133
  * wait is bounded by the CHILD'S OWN LIFE, never an arbitrary budget: verdict recorded →
99
134
  * the answer; failure statement recorded → the failure; child dead with neither (one
100
135
  * last read closes the exit race) → a typed failed outcome naming the retry.
136
+ * While it waits it TICKS (ruling 2026-09-05): `onTick({elapsedMs})` every `tickMs` — the one
137
+ * signal a transport forwards as MCP progress so a client's per-tool clock knows the judgment
138
+ * is still running. No `onTick`, no ticking.
101
139
  * @returns {Promise<{verdict: 'accepted'|'rejected', reason: string}
102
140
  * |{failed: true, reason: string}>}
103
141
  */
104
142
  export async function awaitVerdict({
105
143
  taskId, pid, orgId, query, since,
106
144
  pollMs = 1000, isAlive = pidAlive, sleep = (ms) => new Promise((r) => setTimeout(r, ms)),
145
+ onTick = null, tickMs = null, now = Date.now,
107
146
  }) {
108
147
  const verificationTask = isVerificationTask(taskId) ? taskId : verificationTaskId(taskId);
109
- const originalTask = verificationTask.slice('verify:'.length);
148
+ const originalTask = verifiedTaskId(verificationTask);
149
+ const started = now();
150
+ let nextTick = onTick && tickMs ? started + tickMs : null;
110
151
  let lastChance = false;
111
152
  for (;;) {
153
+ if (nextTick !== null && now() >= nextTick) {
154
+ onTick({ elapsedMs: now() - started });
155
+ nextTick += tickMs;
156
+ }
112
157
  const { rows } = await query(
113
158
  `SELECT v.result, s.proposition
114
159
  FROM cell.verification v
@@ -136,7 +181,7 @@ export async function awaitVerdict({
136
181
  const { rows: fail } = await query(
137
182
  `SELECT proposition FROM cell.agent_statement
138
183
  WHERE org_id = $1 AND task_id = $2 AND asserted_at > $3
139
- AND ${isEngineFailureSql('evidence_refs')}
184
+ AND ${isVerifyStallSql('evidence_refs')}
140
185
  ORDER BY asserted_at DESC LIMIT 1`,
141
186
  [orgId, verificationTask, since]);
142
187
  if (fail[0]) return { failed: true, reason: fail[0].proposition };
@@ -159,11 +204,20 @@ export async function awaitVerdict({
159
204
  * await its verdict; when the substrate is REMOTE (the cloud), this seam is the one place
160
205
  * that flips to dispatch-and-return. Never an engine inside the server either way.
161
206
  */
162
- export function verifierSeam({ orgId, query, paths, cwd, env = process.env }) {
163
- return async ({ taskId, engine = null }) => {
207
+ export function verifierSeam({
208
+ orgId, query, paths, cwd, env = process.env, progressIntervalMs = null,
209
+ spawn = undefined, pollMs = undefined, sleep = undefined, now = undefined, isAlive = undefined,
210
+ }) {
211
+ const waitOptions = Object.fromEntries(Object.entries({ pollMs, sleep, now, isAlive }).filter(([, v]) => v !== undefined));
212
+ return async ({ taskId, engine = null, progress = null }) => {
164
213
  const since = new Date().toISOString();
165
- const out = await dispatchVerification({ taskId, engine, orgId, query, paths, cwd, env });
166
- const outcome = await awaitVerdict({ taskId, pid: out.pid, orgId, query, since });
214
+ const out = await dispatchVerification({ taskId, engine, orgId, query, paths, cwd, env, ...(spawn && { spawn }) });
215
+ // The caller's progress emitter (a transport's MCP notification, the CLI's stderr) hears one
216
+ // line per interval — Node's words, the transport only forwards them.
217
+ const onTick = progress && progressIntervalMs
218
+ ? ({ elapsedMs }) => progress(`verifying ${taskId} — ${Math.round(elapsedMs / 1000)}s`)
219
+ : null;
220
+ const outcome = await awaitVerdict({ taskId, pid: out.pid, orgId, query, since, onTick, tickMs: progressIntervalMs, ...waitOptions });
167
221
  return { ...outcome, log: out.log };
168
222
  };
169
223
  }
package/src/wire.mjs CHANGED
@@ -46,6 +46,12 @@ export function noticeFor(kind, taskId, via = null) {
46
46
  if (kind === 'rejected') return { text: `✗ '${taskId}' reopened — verification rejected.`, tone: 'amber' };
47
47
  if (kind === 'settled') return { text: `✓ '${taskId}' verified — settled.`, tone: 'sage' };
48
48
  if (kind === 'verify_failed') return { text: `✗ verification of '${taskId}' failed${via ? ` (${via})` : ''} — retry from the glass.`, tone: 'amber' };
49
+ // The engine update (ruling 2026-09-05): via = the engine's display name (and, failing, the CLI's tail).
50
+ if (kind === 'engine_updated') return { text: `✓ ${via} updated — re-verifying.`, tone: 'sage' };
51
+ if (kind === 'engine_update_failed') {
52
+ const [name, ...tail] = String(via ?? 'engine').split(': ');
53
+ return { text: `✗ ${name} update failed${tail.length ? ` — ${tail.join(': ')}` : ''}.`, tone: 'amber' };
54
+ }
49
55
  return null;
50
56
  }
51
57
 
@@ -54,7 +60,7 @@ export async function emit(client, { kind, task_id, via, app }) {
54
60
  await client.query('SELECT pg_notify($1, $2)',
55
61
  [WIRE_CHANNEL, JSON.stringify({
56
62
  kind, task_id: task_id ?? null, via: via ?? null,
57
- app: app ?? null, // the act's living app {bundle, pid} — a homeless task still knows where it is spoken from
63
+ app: app ?? null, // the act's living app {bundle, pid} — the glass can switch to it before the record is re-read
58
64
  at: new Date().toISOString(),
59
65
  })]);
60
66
  } catch (e) {
package/plugin/.mcp.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "mcpServers": {
3
- "oathe": {
4
- "command": "oathe",
5
- "args": [
6
- "mcp"
7
- ]
8
- }
9
- }
10
- }