@oathe/oathe 0.4.3 → 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 +206 -34
- 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 +24 -0
- package/src/context.mjs +1 -1
- package/src/device.mjs +106 -0
- package/src/doctor.mjs +110 -9
- 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 +107 -20
- 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 +44 -41
- 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 +48 -4
- 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/doctor.mjs
CHANGED
|
@@ -8,6 +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';
|
|
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
|
+
}
|
|
34
|
+
import { defaultExec } from './harnesses/harness.mjs';
|
|
35
|
+
import { byName } from './harnesses/catalog.mjs';
|
|
11
36
|
|
|
12
37
|
function verifyJsonRow(row) {
|
|
13
38
|
if (!fs.existsSync(row.file)) return 'file-missing';
|
|
@@ -22,17 +47,40 @@ function verifyJsonRow(row) {
|
|
|
22
47
|
return sha256Hex(JSON.stringify(entries)) === row.sha256 ? 'ok' : 'user-edited';
|
|
23
48
|
}
|
|
24
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
|
+
|
|
25
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
|
|
26
59
|
if (!fs.existsSync(row.file)) return 'file-missing';
|
|
27
|
-
const block = new FencedBlock({ style: FENCE_STYLES[row.detail?.style ?? 'hash'] });
|
|
28
60
|
const seen = block.read(fs.readFileSync(row.file, 'utf8'));
|
|
29
61
|
if (!seen.present) return 'removed';
|
|
30
62
|
return sha256Hex(seen.blockText) === row.sha256 ? 'ok' : 'user-edited';
|
|
31
63
|
}
|
|
32
64
|
|
|
33
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');
|
|
34
70
|
if (!fs.existsSync(row.file)) return 'file-missing';
|
|
35
|
-
|
|
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';
|
|
36
84
|
}
|
|
37
85
|
|
|
38
86
|
function verifyJsonArrayRow(row) {
|
|
@@ -66,9 +114,12 @@ export function traceStatusOf(error) {
|
|
|
66
114
|
// A LaunchAgent is a whole-file write: present and byte-identical to what init recorded, or
|
|
67
115
|
// user-edited; gone is gone. (The notch ships with the package — every darwin manifest
|
|
68
116
|
// carries this row now.)
|
|
69
|
-
|
|
117
|
+
// …and "ok" means launchd RUNS it: an agent on disk that launchd dropped (the asynchronous
|
|
118
|
+
// bootout race, a bootout by hand) is the not-running notch the person is staring at.
|
|
119
|
+
function verifyLaunchAgentRow(row, { launchd }) {
|
|
70
120
|
if (!fs.existsSync(row.file)) return 'file-missing';
|
|
71
|
-
|
|
121
|
+
if (sha256Hex(fs.readFileSync(row.file, 'utf8')) !== row.sha256) return 'user-edited';
|
|
122
|
+
return launchd(path.basename(row.file, '.plist')).pid !== null ? 'ok' : 'not-running';
|
|
72
123
|
}
|
|
73
124
|
|
|
74
125
|
// The materialized notch copy: the row's detail names the binary inside the key dir; ok
|
|
@@ -80,9 +131,28 @@ function verifyNotchAppRow(row) {
|
|
|
80
131
|
return sha256Hex(fs.readFileSync(binary)) === row.sha256 ? 'ok' : 'user-edited';
|
|
81
132
|
}
|
|
82
133
|
|
|
83
|
-
|
|
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 = {
|
|
84
153
|
'json-path': verifyJsonRow, fence: verifyFenceRow, 'cli-managed': verifyCliRow, 'json-array': verifyJsonArrayRow,
|
|
85
|
-
'launch-agent': verifyLaunchAgentRow, 'notch-app': verifyNotchAppRow,
|
|
154
|
+
'launch-agent': verifyLaunchAgentRow, 'notch-app': verifyNotchAppRow, 'oathe-shim': verifyWholeFileRow,
|
|
155
|
+
'device-id': verifyWholeFileRow, 'cli-address': verifyCliAddressRow,
|
|
86
156
|
};
|
|
87
157
|
|
|
88
158
|
/**
|
|
@@ -115,7 +185,18 @@ export async function runSurfaceReport({ env = process.env, cwd = () => process.
|
|
|
115
185
|
}
|
|
116
186
|
|
|
117
187
|
/** @returns {Promise<{rows: object[], substrate: object, plugin: {resolves: boolean, detail: string|null}}>} */
|
|
118
|
-
|
|
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
|
+
|
|
197
|
+
export async function runDoctor({ env = process.env, exec = defaultExec } = {}) {
|
|
198
|
+
const launchd = (label) => launchdJob({ label, exec });
|
|
199
|
+
const probe = (file, args) => spawnSync(file, args, { encoding: 'utf8', env: { ...env, PATH: agentPathEnv() }, timeout: 20_000 });
|
|
119
200
|
const ctx = buildContext({ env });
|
|
120
201
|
const { manifest, substrate, paths, harnesses } = ctx;
|
|
121
202
|
try {
|
|
@@ -130,7 +211,7 @@ export async function runDoctor({ env = process.env } = {}) {
|
|
|
130
211
|
file: row.file,
|
|
131
212
|
kind: row.kind,
|
|
132
213
|
block_version: row.block_version,
|
|
133
|
-
status: (
|
|
214
|
+
status: verifierFor(row)(row, { launchd, probe }),
|
|
134
215
|
}));
|
|
135
216
|
// The trace-contract monitor: both vendors disclaim transcript-schema stability, so the
|
|
136
217
|
// doctor validates the NEWEST live record in each engine's store against docs/traces.md and
|
|
@@ -161,7 +242,11 @@ export async function runDoctor({ env = process.env } = {}) {
|
|
|
161
242
|
const fidelity = await fidelityOf({
|
|
162
243
|
store, project: (file) => projectAnnotated(file, { home }), fidelity: capability.fidelity, files, traceStatus: traceStatusOf,
|
|
163
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;
|
|
164
248
|
const failures = [
|
|
249
|
+
...(stagingDrift ? [stagingDrift] : []),
|
|
165
250
|
...census.undeclared.map((u) => `undeclared ${u.channel}.${u.type} ×${u.count} (first: ${u.example})`),
|
|
166
251
|
...fidelity.projectionErrors.filter((p) => p.status === 'DRIFT').map((p) => `${p.file}: ${p.detail}`),
|
|
167
252
|
...fidelity.probes.flatMap((p) => p.failed.map((f) => `${p.probe}: ${f.file}: ${f.detail}`)),
|
|
@@ -204,7 +289,23 @@ export async function runDoctor({ env = process.env } = {}) {
|
|
|
204
289
|
capabilities: null, error: String(e?.message || e), probe: null };
|
|
205
290
|
}
|
|
206
291
|
|
|
207
|
-
|
|
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 };
|
|
208
309
|
} finally {
|
|
209
310
|
await substrate.close();
|
|
210
311
|
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// oathe — the engine update as a CLAIM (ruling 2026-09-05, launch/2026-09-05-engines-places-plan.md
|
|
2
|
+
// Leg D). A judgment named an engine out of date; the fix is the engine's OWN updater, run by
|
|
3
|
+
// the machine and recorded like every other act: the update child claims `update:<harness>`
|
|
4
|
+
// (so the glass, `oathe ls` and attention read "updating <Name>" off one fact and a feed
|
|
5
|
+
// restart forgets nothing), states what it runs, runs it into a log, asserts done with the
|
|
6
|
+
// version measured after, settles under the operator seat at the deterministic bar, and
|
|
7
|
+
// re-verifies what the old version failed. A failure is a statement (ref update-failure:<h>),
|
|
8
|
+
// a yield, an amber notice and a typed refusal — never a silent success.
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { spawn as nodeSpawn } from 'node:child_process';
|
|
13
|
+
|
|
14
|
+
import { byName, displayFor } from './harnesses/catalog.mjs';
|
|
15
|
+
import { updateTaskId, updateObjective } from './plans.mjs';
|
|
16
|
+
import { updateFailureRef } from './statements.mjs';
|
|
17
|
+
import { emit as wireEmit } from './wire.mjs';
|
|
18
|
+
import { Verifier, completionStatementOf, settleReview } from './verifier.mjs';
|
|
19
|
+
import { Pager } from './pager.mjs';
|
|
20
|
+
|
|
21
|
+
export class EngineUpdateError extends Error {
|
|
22
|
+
constructor(code, message, details = {}) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.details = details;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One process, its output tee'd to a log; resolves on exit with the stderr tail for the record. */
|
|
30
|
+
function runToLog({ spawn, bin, args, env, log }) {
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
const out = fs.createWriteStream(log, { flags: 'a' });
|
|
33
|
+
out.write(`$ ${[bin, ...args].join(' ')}\n`);
|
|
34
|
+
let tail = '';
|
|
35
|
+
let stdout = '';
|
|
36
|
+
let child;
|
|
37
|
+
try {
|
|
38
|
+
child = spawn(bin, args, { env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
39
|
+
} catch (error) {
|
|
40
|
+
out.end(); resolve({ status: null, error, tail: error.message, stdout }); return;
|
|
41
|
+
}
|
|
42
|
+
child.stdout.on('data', (d) => { out.write(d); stdout += d; });
|
|
43
|
+
child.stderr.on('data', (d) => { out.write(d); tail = (tail + d).slice(-2000); });
|
|
44
|
+
child.on('error', (error) => { out.end(); resolve({ status: null, error, tail: tail || error.message, stdout }); });
|
|
45
|
+
child.on('close', (status) => { out.end(); resolve({ status, tail: tail.trim().slice(-300), stdout }); });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class EngineUpdate {
|
|
50
|
+
/**
|
|
51
|
+
* @param {{substrate: object, paths: object, workspace: string, config: object, operatorPrincipal: string,
|
|
52
|
+
* manifest: {cliAddressFor: Function}, provider?: object|null, env?: object, spawn?: Function,
|
|
53
|
+
* onStart?: Function}} o onStart({harness, address, before, command, log}) — a caller's line before the run
|
|
54
|
+
*/
|
|
55
|
+
constructor({ substrate, paths, workspace, config, operatorPrincipal, manifest, provider = null, env = process.env, spawn = nodeSpawn, onStart = () => {} }) {
|
|
56
|
+
this.substrate = substrate;
|
|
57
|
+
this.paths = paths;
|
|
58
|
+
this.config = config;
|
|
59
|
+
this.manifest = manifest;
|
|
60
|
+
this.env = env;
|
|
61
|
+
this.spawn = spawn;
|
|
62
|
+
this.onStart = onStart;
|
|
63
|
+
this.orgId = config.get('org');
|
|
64
|
+
this.operatorPrincipal = operatorPrincipal;
|
|
65
|
+
// The verification lane's own actor: its tools speak as the system seat, its runtime
|
|
66
|
+
// settles, and it re-verifies — one object, one close().
|
|
67
|
+
this.verifier = new Verifier({
|
|
68
|
+
substrate, paths, workspace, config, operatorPrincipal, provider, env,
|
|
69
|
+
addressFor: (engine) => manifest.cliAddressFor(engine),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {{harness: string, thenVerify?: boolean, task?: string|null}} o
|
|
75
|
+
* @returns {Promise<{harness: string, address: string, before: string, after: string, update_task: string,
|
|
76
|
+
* log: string, reverified: Array<{task_id: string, verdict?: string, error?: string}>}>}
|
|
77
|
+
*/
|
|
78
|
+
async run({ harness, thenVerify = false, task = null }) {
|
|
79
|
+
const adapter = this.#adapter(harness);
|
|
80
|
+
const address = this.manifest.cliAddressFor(harness); // the recorded address or a refusal — never a PATH guess
|
|
81
|
+
if (address === null) {
|
|
82
|
+
throw new EngineUpdateError('OATHE_ENGINE_MISSING',
|
|
83
|
+
`the '${harness}' CLI: no address was recorded for it — run oathe init to record where it is`, { harness });
|
|
84
|
+
}
|
|
85
|
+
const name = displayFor(harness) ?? harness;
|
|
86
|
+
const updateTask = updateTaskId(harness);
|
|
87
|
+
fs.mkdirSync(this.paths.logsDir, { recursive: true });
|
|
88
|
+
const log = path.join(this.paths.logsDir, `update-${harness}.log`);
|
|
89
|
+
fs.writeFileSync(log, '');
|
|
90
|
+
const before = await this.#version(address, adapter);
|
|
91
|
+
const [bin, args] = adapter.install.update(address);
|
|
92
|
+
const command = [bin, ...args].join(' ');
|
|
93
|
+
|
|
94
|
+
const tools = this.verifier.tools;
|
|
95
|
+
await tools.oathe_claim({ task_id: updateTask, objective: updateObjective(harness, address) });
|
|
96
|
+
await wireEmit(this.substrate, { kind: 'engine_update_started', task_id: updateTask, via: name });
|
|
97
|
+
await tools.oathe_statement({ task_id: updateTask, proposition: `updating ${name} (${before}) via ${command}`, evidence_ref: `log:${log}` });
|
|
98
|
+
this.onStart({ harness, address, before, command, log });
|
|
99
|
+
|
|
100
|
+
const run = await runToLog({ spawn: this.spawn, bin, args, env: this.env, log });
|
|
101
|
+
if (run.status !== 0) {
|
|
102
|
+
const tail = run.tail || `exit ${run.status}`;
|
|
103
|
+
const proposition = `update of ${harness} failed: ${tail}`;
|
|
104
|
+
try {
|
|
105
|
+
await tools.oathe_statement({ task_id: updateTask, proposition, evidence_ref: updateFailureRef(harness) });
|
|
106
|
+
await tools.oathe_yield({ task_id: updateTask, note: `${name}'s updater refused — read ${log}, fix the cause, and update again` });
|
|
107
|
+
} catch { /* best-effort release — the primary failure must surface either way */ }
|
|
108
|
+
await wireEmit(this.substrate, { kind: 'engine_update_failed', task_id: updateTask, via: `${name}: ${tail}` });
|
|
109
|
+
throw new EngineUpdateError('OATHE_ENGINE_UPDATE_FAILED',
|
|
110
|
+
`${command} exited ${run.status ?? 'without running'}: ${tail} — log: ${log}`, { harness, address, status: run.status, log });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const after = await this.#version(address, adapter);
|
|
114
|
+
const evidenceRef = `version:${after}`;
|
|
115
|
+
const done = await tools.oathe_done({ task_id: updateTask, proposition: `updated ${name}: ${before} → ${after}`, evidence_ref: evidenceRef });
|
|
116
|
+
// The update's own review settles under the OPERATOR seat at the deterministic bar — the
|
|
117
|
+
// same close a judgment's verify: task gets (src/verifier.mjs settleReview).
|
|
118
|
+
await settleReview({
|
|
119
|
+
runtime: await this.verifier.runtime(), seat: this.operatorPrincipal, orgId: this.orgId, taskId: updateTask,
|
|
120
|
+
plan: await this.verifier.planOf(updateTask),
|
|
121
|
+
stmt: await completionStatementOf({ substrate: this.substrate, orgId: this.orgId, taskId: updateTask }),
|
|
122
|
+
evidenceRefs: [evidenceRef], tracePath: `statement:${done.statement_id}`,
|
|
123
|
+
});
|
|
124
|
+
await wireEmit(this.substrate, { kind: 'engine_updated', task_id: updateTask, via: name });
|
|
125
|
+
|
|
126
|
+
const reverified = thenVerify ? await this.#reverify({ harness, task }) : [];
|
|
127
|
+
return { harness, address, before, after, update_task: updateTask, log, reverified };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Every stall this engine's old version caused (the pager's own reading), or the one task named — judged again by the updated engine. */
|
|
131
|
+
async #reverify({ harness, task }) {
|
|
132
|
+
const targets = task ? [task]
|
|
133
|
+
: (await new Pager({ client: this.substrate, identity: { orgId: this.orgId }, config: this.config }).breaches())
|
|
134
|
+
.filter((b) => b.kind === 'stalled' && b.engine === harness && b.cause === 'outdated' && !b.busy)
|
|
135
|
+
.map((b) => b.task_id);
|
|
136
|
+
const out = [];
|
|
137
|
+
for (const taskId of targets) {
|
|
138
|
+
try {
|
|
139
|
+
const v = await this.verifier.verify({ taskId, engine: harness });
|
|
140
|
+
out.push({ task_id: taskId, verdict: v.verdict });
|
|
141
|
+
} catch (e) {
|
|
142
|
+
out.push({ task_id: taskId, error: `[${e?.code ?? 'error'}] ${String(e?.message ?? e).slice(0, 200)}` });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#adapter(harness) {
|
|
149
|
+
let adapter;
|
|
150
|
+
try { adapter = byName(harness); } catch (e) { throw new EngineUpdateError('OATHE_ENGINE_UNKNOWN', e.message, { harness }); }
|
|
151
|
+
if (typeof adapter.install?.update !== 'function') {
|
|
152
|
+
throw new EngineUpdateError('OATHE_ENGINE_UPDATE_UNSUPPORTED',
|
|
153
|
+
`'${harness}' declares no in-place updater (src/harnesses/${harness}.mjs install.update) — update it the way you installed it`, { harness });
|
|
154
|
+
}
|
|
155
|
+
return adapter;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** The CLI's version, measured (`<address> <versionArgs>`); 'unknown' when it will not say. */
|
|
159
|
+
async #version(address, adapter) {
|
|
160
|
+
const scratch = path.join(this.paths.logsDir, `.version-${path.basename(address)}.log`);
|
|
161
|
+
const run = await runToLog({ spawn: this.spawn, bin: address, args: adapter.install.versionArgs, env: this.env, log: scratch });
|
|
162
|
+
try { fs.rmSync(scratch, { force: true }); } catch { /* a scratch file */ }
|
|
163
|
+
const line = String(run.stdout ?? '').trim().split('\n')[0];
|
|
164
|
+
return run.status === 0 && line ? line : 'unknown';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async close() {
|
|
168
|
+
await this.verifier.close();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// oathe — evidence discovery: the read-time half of the evidence rails. The substrate's
|
|
2
|
+
// tool results echo each claim's UUID into whatever transcript the harness keeps, so the
|
|
3
|
+
// record self-fingerprints — a claim's evidence can be FOUND from the record alone, with no
|
|
4
|
+
// dependence on hooks, registration, or the speaker having known its session (the ChatGPT
|
|
5
|
+
// desktop class of false rejection, live 2026-08-31 and 2026-09-04: the work sat on disk
|
|
6
|
+
// while the verifier judged an empty record).
|
|
7
|
+
//
|
|
8
|
+
// Two rails, kept apart on purpose: trace-link statements stay the act-time ATTRIBUTION rail
|
|
9
|
+
// (board, notch, reclaim bundle — cheap, per act); discovery is the read-time EVIDENCE rail.
|
|
10
|
+
// gather() serves their union — the record's own word leads, discovery only ever adds.
|
|
11
|
+
//
|
|
12
|
+
// Membership is PERFORMANCE, never mention: a discovered file must project to a trajectory
|
|
13
|
+
// whose claim intervals name the task (an investigator's transcript contains the UUID; only
|
|
14
|
+
// the worker's contains the acts). The verifier's own transcript claims `verify:<task>`,
|
|
15
|
+
// never the task, so the judge's record stays out of the evidence it judges — the same line
|
|
16
|
+
// LINKABLE draws (src/wire.mjs).
|
|
17
|
+
|
|
18
|
+
import { traceStores, byName, transcriptFor } from './harnesses/catalog.mjs';
|
|
19
|
+
import { projectAnnotated } from './oathe-annotator.mjs';
|
|
20
|
+
import { claimIntervals } from './atif.mjs';
|
|
21
|
+
import { taskTraceLinksSql, TRACE_SUBJECT_PREFIX } from './statements.mjs';
|
|
22
|
+
import { TraceContractError } from './traces.mjs';
|
|
23
|
+
|
|
24
|
+
// Design constants, not tunables — no consumer has a story for turning them (founder ruling
|
|
25
|
+
// 2026-09-01: no speculative config). The skew absorbs clock drift between the substrate's
|
|
26
|
+
// claimed_at and the store's mtimes; the cap bounds one gather's disk read.
|
|
27
|
+
const CLAIM_CLOCK_SKEW_MS = 5 * 60_000;
|
|
28
|
+
const DISCOVERY_MAX_FILES = 4000;
|
|
29
|
+
|
|
30
|
+
async function defaultStoresFor({ home }) {
|
|
31
|
+
const stores = [];
|
|
32
|
+
for (const name of traceStores()) {
|
|
33
|
+
const { traces } = byName(name);
|
|
34
|
+
stores.push(await traces.store({ home }));
|
|
35
|
+
}
|
|
36
|
+
return stores;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class EvidenceDiscovery {
|
|
40
|
+
/**
|
|
41
|
+
* @param {{client: {query: Function}, orgId: string, home?: string,
|
|
42
|
+
* storesFor?: ({home}) => Promise<object[]>, maxFiles?: number}} o
|
|
43
|
+
* client/orgId read the record; home roots the stores; storesFor and maxFiles are seams.
|
|
44
|
+
*/
|
|
45
|
+
constructor({ client, orgId, home = undefined, storesFor = defaultStoresFor, maxFiles = DISCOVERY_MAX_FILES, project = projectAnnotated }) {
|
|
46
|
+
this.project = project; // the projector seam (tests inject a failing one)
|
|
47
|
+
this.client = client;
|
|
48
|
+
this.orgId = orgId;
|
|
49
|
+
this.home = home;
|
|
50
|
+
this.storesFor = storesFor;
|
|
51
|
+
this.maxFiles = maxFiles;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Project ONE file, and let nothing die untyped: a TraceContractError (a torn line, an
|
|
56
|
+
* unreadable file) passes through as the record's own refusal; anything else the projector
|
|
57
|
+
* throws becomes TRACE_PROJECTION_FAILED naming the file and the cause — the verifier's stall
|
|
58
|
+
* note reads a file and a reason, never a stack (Greptile round 3 on PR #37, 2026-09-06).
|
|
59
|
+
*/
|
|
60
|
+
async #project(file) {
|
|
61
|
+
try {
|
|
62
|
+
return await this.project(file, { home: this.home });
|
|
63
|
+
} catch (e) {
|
|
64
|
+
if (e instanceof TraceContractError) throw e;
|
|
65
|
+
throw new TraceContractError('TRACE_PROJECTION_FAILED',
|
|
66
|
+
`${file} could not be projected: ${String(e?.message ?? e)}`, { file, cause: e?.code ?? e?.name ?? 'error' });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The task's recorded trace links, resolved to the files the sessions actually write. */
|
|
71
|
+
async #linked(taskId) {
|
|
72
|
+
const { rows } = await this.client.query(taskTraceLinksSql(), [this.orgId, taskId]);
|
|
73
|
+
const paths = [];
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
for (const row of rows) {
|
|
76
|
+
const sessionId = row.subject_ref.slice(TRACE_SUBJECT_PREFIX.length);
|
|
77
|
+
for (const ref of row.evidence_refs) {
|
|
78
|
+
const file = transcriptFor({ sessionId, reportedPath: ref, home: this.home });
|
|
79
|
+
if (seen.has(file)) continue;
|
|
80
|
+
seen.add(file);
|
|
81
|
+
paths.push(file);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return paths;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Does the record ATTEST attribution at all? A store-less surface (cursor) links with
|
|
89
|
+
* empty evidence — that is attribution without a transcript, and it keeps the claim
|
|
90
|
+
* judgeable; a task with no link and no discovery hit has an empty record instead.
|
|
91
|
+
*/
|
|
92
|
+
async hasAttribution(taskId) {
|
|
93
|
+
const { rows } = await this.client.query(taskTraceLinksSql(), [this.orgId, taskId]);
|
|
94
|
+
return rows.length > 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Every claim ever taken on the task — the needles, and the window's opening. */
|
|
98
|
+
async #claims(taskId) {
|
|
99
|
+
const { rows } = await this.client.query(
|
|
100
|
+
`SELECT work_claim_id, claimed_at FROM cell.work_claim
|
|
101
|
+
WHERE org_id = $1 AND task_id = $2 ORDER BY claimed_at`,
|
|
102
|
+
[this.orgId, taskId]);
|
|
103
|
+
return rows;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The whole evidence read for one task: recorded links ∪ fingerprint discovery, projected,
|
|
108
|
+
* performance-confirmed (discovered only), deterministically ordered — linked first in the
|
|
109
|
+
* record's own order, then discovered by store order and path. `unreadable` names every
|
|
110
|
+
* store file in the window the byte scan could not read (by path and cause): reported, never
|
|
111
|
+
* a stall — a file that cannot be read cannot be known to be this task's, and an unrelated
|
|
112
|
+
* one must never block the task's own evidence (Greptile on PR #37, 2026-09-04). A file that
|
|
113
|
+
* DOES name the claim and cannot project still refuses typed: that one may be the evidence.
|
|
114
|
+
* @returns {Promise<{traces: Array<{path: string, trajectory: object, via: 'linked'|'discovered'}>,
|
|
115
|
+
* unreadable: Array<{path: string, code: string, message: string}>}>}
|
|
116
|
+
*/
|
|
117
|
+
async read({ taskId }) {
|
|
118
|
+
const linked = await this.#linked(taskId);
|
|
119
|
+
const claims = await this.#claims(taskId);
|
|
120
|
+
const traces = [];
|
|
121
|
+
const unreadable = [];
|
|
122
|
+
for (const file of linked) {
|
|
123
|
+
traces.push({ path: file, trajectory: await this.#project(file), via: 'linked' });
|
|
124
|
+
}
|
|
125
|
+
if (claims.length === 0) return { traces, unreadable };
|
|
126
|
+
|
|
127
|
+
const sinceMs = Date.parse(claims[0].claimed_at) - CLAIM_CLOCK_SKEW_MS;
|
|
128
|
+
const needles = claims.map((c) => c.work_claim_id);
|
|
129
|
+
const linkedSet = new Set(linked);
|
|
130
|
+
for (const store of await this.storesFor({ home: this.home })) {
|
|
131
|
+
let candidates;
|
|
132
|
+
try {
|
|
133
|
+
candidates = store.evidenceFiles({ sinceMs });
|
|
134
|
+
} catch (e) {
|
|
135
|
+
// A store that cannot be enumerated (its root vanished or unreadable mid-walk) is
|
|
136
|
+
// reported like an unreadable file — the other stores still serve; never a stall.
|
|
137
|
+
unreadable.push({ path: `${store.harness} store`, code: e?.code ?? 'ENUMERATION_FAILED', message: String(e?.message ?? e) });
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (candidates.length > this.maxFiles) {
|
|
141
|
+
throw new TraceContractError('TRACE_DISCOVERY_OVERFLOW',
|
|
142
|
+
`the ${store.harness} store holds ${candidates.length} files in this claim's window `
|
|
143
|
+
+ `(cap ${this.maxFiles}) — refusing a partial scan; narrow the window or thin the store`,
|
|
144
|
+
{ harness: store.harness, candidates: candidates.length });
|
|
145
|
+
}
|
|
146
|
+
for (const file of candidates) {
|
|
147
|
+
if (linkedSet.has(file)) continue;
|
|
148
|
+
let names;
|
|
149
|
+
try {
|
|
150
|
+
names = needles.some((needle) => store.contains(file, needle));
|
|
151
|
+
} catch (e) {
|
|
152
|
+
if (!(e instanceof TraceContractError)) throw e;
|
|
153
|
+
unreadable.push({ path: file, code: e.code, message: e.message });
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (!names) continue;
|
|
157
|
+
// The projector, not the byte scan, decides membership: performing, never mentioning.
|
|
158
|
+
const trajectory = await this.#project(file);
|
|
159
|
+
if (!claimIntervals(trajectory).some((i) => i.task_id === taskId)) continue;
|
|
160
|
+
traces.push({ path: file, trajectory, via: 'discovered' });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return { traces, unreadable };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The evidence alone — read() for a caller that has no use for the unreadable list. */
|
|
167
|
+
async gather({ taskId }) {
|
|
168
|
+
return (await this.read({ taskId })).traces;
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/fence.mjs
CHANGED
|
@@ -39,9 +39,9 @@ export function globalFenceBody() {
|
|
|
39
39
|
'',
|
|
40
40
|
wrap(`Every session on this machine has an Oathe board. ${SPEECH_ACT_RULE} Where a session opens `
|
|
41
41
|
+ 'on a project folder, that folder\'s board loads with it. A session with no project folder '
|
|
42
|
-
+ '(ChatGPT desktop runs from a staging directory) sees the machine-wide board
|
|
43
|
-
+ '
|
|
44
|
-
+ '
|
|
42
|
+
+ '(ChatGPT desktop runs from a staging directory) sees the machine-wide board; work claimed '
|
|
43
|
+
+ 'there lives in the app until a folder picks it up, and every place that picked it up keeps '
|
|
44
|
+
+ 'seeing it. `continue <task>` picks work back up.'),
|
|
45
45
|
].join('\n');
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -82,9 +82,51 @@ export function capabilityTable() {
|
|
|
82
82
|
synthetic: C.isSyntheticWorkspaceDir !== Harness.isSyntheticWorkspaceDir,
|
|
83
83
|
install: C.install !== null,
|
|
84
84
|
docs: C.docs.length > 0,
|
|
85
|
+
attestation: C.attestation,
|
|
86
|
+
mcpToolTimeout: C.mcpToolTimeout !== null,
|
|
85
87
|
}]));
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Attestation by SURFACE name (the speaker's `surface`, as the adapters name it): which
|
|
92
|
+
* adapter owns the surface and whether its sessions register through hooks. `null` for a
|
|
93
|
+
* surface nobody owns — the claim gate refuses those.
|
|
94
|
+
* @returns {{harness: string, attestation: 'hooks'|'hookless'}|null}
|
|
95
|
+
*/
|
|
96
|
+
export function attestationFor(surface) {
|
|
97
|
+
if (!surface) return null;
|
|
98
|
+
for (const C of HARNESS_CLASSES) {
|
|
99
|
+
const declared = C.attestation?.[surface];
|
|
100
|
+
if (declared) return { harness: C.harnessName, attestation: declared };
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Where work lives (ruling 2026-09-05), asked by SURFACE name: the word a place wears on every
|
|
107
|
+
* surface (`surfaces.display`), and whether the app recorded on an act is a place the glass can
|
|
108
|
+
* resume INTO by opening it (`surfaces.resumable` — the desktop app IS where the work lives; a
|
|
109
|
+
* terminal is not). Adapter facts; no literal outside src/harnesses/.
|
|
110
|
+
*/
|
|
111
|
+
export function displayFor(surface) {
|
|
112
|
+
if (!surface) return null;
|
|
113
|
+
for (const C of HARNESS_CLASSES) {
|
|
114
|
+
const word = C.surfaces?.display?.[surface];
|
|
115
|
+
if (word) return word;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function appResumable(surface) {
|
|
121
|
+
if (!surface) return false;
|
|
122
|
+
return HARNESS_CLASSES.some((C) => C.surfaces?.resumable?.includes(surface) ?? false);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Can the glass update this harness's CLI in place? The adapter declares `install.update` (ruling 2026-09-05). */
|
|
126
|
+
export function updatable(name) {
|
|
127
|
+
return typeof HARNESS_CLASSES.find((C) => C.harnessName === name)?.install?.update === 'function';
|
|
128
|
+
}
|
|
129
|
+
|
|
88
130
|
/** [name, envVar] pairs for every adapter that documents a project-dir env var. */
|
|
89
131
|
export function projectDirEnvVars() {
|
|
90
132
|
return HARNESS_CLASSES.filter((C) => C.projectDirEnvVar !== null)
|
|
@@ -173,13 +215,13 @@ export function transcriptFor({ sessionId, reportedPath, home } = {}) {
|
|
|
173
215
|
}
|
|
174
216
|
|
|
175
217
|
/** Instantiate every adapter whose wiring exists — the init/uninstall roster. */
|
|
176
|
-
export function buildWireable({ home, envPath, paths, exec }) {
|
|
177
|
-
return HARNESS_CLASSES.filter((C) => C.wiring !== null).map((C) => new C({ home, envPath, paths, exec }));
|
|
218
|
+
export function buildWireable({ home, envPath, paths, exec, config = null }) {
|
|
219
|
+
return HARNESS_CLASSES.filter((C) => C.wiring !== null).map((C) => new C({ home, envPath, paths, exec, config }));
|
|
178
220
|
}
|
|
179
221
|
|
|
180
222
|
/** Instantiate every adapter — detection sweeps (the picker census) see them all. */
|
|
181
|
-
export function buildAll({ home, envPath, paths, exec }) {
|
|
182
|
-
return HARNESS_CLASSES.map((C) => new C({ home, envPath, paths, exec }));
|
|
223
|
+
export function buildAll({ home, envPath, paths, exec, config = null }) {
|
|
224
|
+
return HARNESS_CLASSES.map((C) => new C({ home, envPath, paths, exec, config }));
|
|
183
225
|
}
|
|
184
226
|
|
|
185
227
|
/** The detect-only surfaces as the picker prints them: detected + the manual steps. */
|