@oathe/oathe 0.4.4 → 0.4.5
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.
- package/.claude-plugin/marketplace.json +18 -2
- package/README.md +4 -1
- package/bin/oathe.mjs +199 -35
- package/docs/PRIVACY.md +26 -4
- package/notch/Oathe Notch.app/Contents/Info.plist +1 -1
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/README.md +4 -3
- package/package.json +3 -3
- package/plugin/.claude-plugin/plugin.json +21 -3
- package/plugin/.cursor-plugin/plugin.json +2 -2
- package/plugin/hooks/hooks.json +4 -4
- package/plugin/hooks/lib.mjs +9 -0
- package/plugin/hooks/render-board.mjs +4 -2
- package/src/blocks.mjs +10 -1
- package/src/board-render.mjs +7 -4
- package/src/breach-digest.mjs +75 -10
- package/src/config.mjs +18 -0
- package/src/context.mjs +1 -1
- package/src/device.mjs +106 -0
- package/src/doctor.mjs +101 -6
- package/src/engine-update.mjs +170 -0
- package/src/evidence-discovery.mjs +170 -0
- package/src/fence.mjs +3 -3
- package/src/harnesses/catalog.mjs +46 -4
- package/src/harnesses/claude.mjs +56 -4
- package/src/harnesses/codex-rollout.mjs +110 -21
- package/src/harnesses/codex.mjs +106 -19
- package/src/harnesses/cursor.mjs +31 -18
- package/src/harnesses/harness.mjs +82 -13
- package/src/harnesses/surfaces.mjs +2 -2
- package/src/home.mjs +174 -52
- package/src/init.mjs +27 -2
- package/src/launch.mjs +7 -9
- package/src/launchd.mjs +100 -0
- package/src/manifest.mjs +48 -6
- package/src/mcp/connection.mjs +73 -7
- package/src/mcp/daemon.mjs +123 -0
- package/src/mcp/forwarder.mjs +99 -0
- package/src/mcp/oathe-tools.mjs +392 -145
- package/src/notch-frame.mjs +118 -42
- package/src/notch.mjs +34 -68
- package/src/oathe-annotator.mjs +10 -10
- package/src/pager.mjs +144 -40
- package/src/paths.mjs +1 -0
- package/src/plans.mjs +44 -5
- package/src/registry.mjs +10 -2
- package/src/serve.mjs +82 -0
- package/src/session-host.mjs +1 -1
- package/src/sessions.mjs +39 -8
- package/src/shim.mjs +110 -0
- package/src/speaker.mjs +24 -5
- package/src/statements.mjs +116 -2
- package/src/traces.mjs +61 -19
- package/src/uninstall.mjs +20 -3
- package/src/update.mjs +35 -7
- package/src/verifier.mjs +215 -105
- package/src/verify-dispatch.mjs +86 -32
- package/src/wire.mjs +7 -1
- package/plugin/.mcp.json +0 -10
package/src/verify-dispatch.mjs
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
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,
|
|
53
|
+
ORDER BY claimed_at DESC LIMIT 1`, [orgId, taskId]);
|
|
55
54
|
const latest = rows[0];
|
|
56
|
-
if (latest?.state
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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,
|
|
71
|
-
const logFd = fs.openSync(log, 'w');
|
|
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
|
|
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
|
|
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 ${
|
|
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({
|
|
163
|
-
|
|
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
|
-
|
|
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} —
|
|
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) {
|