@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/harnesses/cursor.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { Harness, HarnessOnboardError } from './harness.mjs';
|
|
|
18
18
|
import { workspaceRootsDialect } from './dialects.mjs';
|
|
19
19
|
import { JsonArrayEntries, JsonEntries } from '../blocks.mjs';
|
|
20
20
|
import { sha256Hex } from '../manifest.mjs';
|
|
21
|
+
import { shimPath } from '../shim.mjs';
|
|
21
22
|
|
|
22
23
|
const HOOK_EVENTS = Object.freeze([
|
|
23
24
|
{ event: 'sessionStart', script: 'render-board' },
|
|
@@ -48,9 +49,15 @@ export class CursorHarness extends Harness {
|
|
|
48
49
|
ownsExec: (exec) => exec.includes(`${path.sep}Cursor.app${path.sep}`)
|
|
49
50
|
|| CursorHarness.cliExecutables.includes(path.basename(exec)),
|
|
50
51
|
name: () => 'cursor',
|
|
52
|
+
display: Object.freeze({ cursor: 'Cursor' }),
|
|
53
|
+
resumable: Object.freeze([]), // a folder's session — the folder is the place
|
|
51
54
|
});
|
|
52
55
|
// cursor/cli-installation.md:10 (pinned 2026-08-29).
|
|
53
|
-
static
|
|
56
|
+
static attestation = Object.freeze({ cursor: 'hooks' });
|
|
57
|
+
// Cursor's pinned MCP docs (cursor/mcp.md, cli-mcp.md) document no per-tool timeout, so
|
|
58
|
+
// there is nothing to write — a stated limitation, not a guess; a live probe is owed.
|
|
59
|
+
static mcpToolTimeout = null;
|
|
60
|
+
static install = Object.freeze({ installer: 'curl https://cursor.com/install -fsS | bash', bin: 'agent', versionArgs: ['--version'], update: null }); // no in-place updater documented
|
|
54
61
|
// Headless: `agent -p --output-format json` → {type:"result", result} (cursor/cli-output-format.md);
|
|
55
62
|
// CI auth CURSOR_API_KEY (cursor/cli-authentication.md:24-37, cli-github-actions.md:17). A fresh
|
|
56
63
|
// project dir is untrusted — the CLI refuses to run there without --trust (observed live 2026-08-29).
|
|
@@ -58,6 +65,7 @@ export class CursorHarness extends Harness {
|
|
|
58
65
|
auth: ['CURSOR_API_KEY'],
|
|
59
66
|
command: (prompt, model = null) => ['agent', ['-p', prompt, '--trust', '--output-format', 'json', ...(model ? ['--model', model] : [])]],
|
|
60
67
|
extract: (stdout) => CursorHarness.extractJsonResult(stdout),
|
|
68
|
+
diagnose: () => null, // unmeasured — stated
|
|
61
69
|
});
|
|
62
70
|
static traces = null; // Cursor keeps no session store we read; its hook payload carries transcript_path: null
|
|
63
71
|
static docs = Object.freeze([
|
|
@@ -90,21 +98,17 @@ export class CursorHarness extends Harness {
|
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
/**
|
|
93
|
-
* The absolute oathe address
|
|
94
|
-
* (npm shims ride `#!/usr/bin/env node`, and a GUI-launched Cursor may not carry node's dir
|
|
95
|
-
* on PATH — the fallback names the runtime explicitly).
|
|
101
|
+
* The absolute oathe address for every cursor-owned entry.
|
|
96
102
|
* @returns {{command: string, args: string[], hookPrefix: string}}
|
|
97
103
|
*/
|
|
98
104
|
#oatheAddress() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
const binPath = path.join(this.paths.packageRoot, 'bin/oathe.mjs');
|
|
107
|
-
return { command: process.execPath, args: [binPath], hookPrefix: `${process.execPath} ${binPath}` };
|
|
105
|
+
// The ONE durable address (connection-lane plan, 2026-09-04): the shim init materializes
|
|
106
|
+
// under the oathe home. The old PATH scan answered differently per environment — the
|
|
107
|
+
// exact class that stranded GUI sessions — and a raw node path was stranded by the next
|
|
108
|
+
// nvm switch. Deterministic from home alone; init writes the shim before any adapter.
|
|
109
|
+
// The hook prefix is QUOTED (review F7): a HOME with a space must not break one dialect.
|
|
110
|
+
const shim = shimPath(this.home);
|
|
111
|
+
return { command: shim, args: [], hookPrefix: `"${shim}"` };
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
#hookEntries(hookPrefix) {
|
|
@@ -113,7 +117,10 @@ export class CursorHarness extends Harness {
|
|
|
113
117
|
return {
|
|
114
118
|
path: ['hooks', event],
|
|
115
119
|
element: { command },
|
|
116
|
-
|
|
120
|
+
// Ownership is the SCHEMA, not this vintage's exact address (review F2): any entry
|
|
121
|
+
// driving `… hook <script>` is ours — an old-address entry converges instead of
|
|
122
|
+
// pairing up with the new one and running every hook twice through a dead path.
|
|
123
|
+
owns: (el) => typeof el?.command === 'string' && el.command.endsWith(` hook ${script}`),
|
|
117
124
|
match: command,
|
|
118
125
|
};
|
|
119
126
|
});
|
|
@@ -154,9 +161,12 @@ export class CursorHarness extends Harness {
|
|
|
154
161
|
const hooksAbsentBefore = !fs.existsSync(this.hooksConfigPath);
|
|
155
162
|
// Version ownership is decided ONCE (the file we created carries our version key) and then
|
|
156
163
|
// carried forward — a re-run must upsert the SAME row identity, never mint a sibling.
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
const priorRow = manifest.rows.find((r) => r.harness === this.name && r.file === this.hooksConfigPath && r.kind === 'json-array');
|
|
165
|
+
if (priorRow && typeof priorRow.detail?.owns_version !== 'boolean') {
|
|
166
|
+
throw new HarnessOnboardError('CURSOR_MANIFEST_ROW_MALFORMED',
|
|
167
|
+
`the recorded ${this.hooksConfigPath} row carries no owns_version — not a row this oathe writes; uninstall with the oathe that wrote it, then run oathe init`, { row: priorRow });
|
|
168
|
+
}
|
|
169
|
+
const ownsVersion = hooksAbsentBefore || (priorRow ? priorRow.detail.owns_version : false);
|
|
160
170
|
|
|
161
171
|
manifest.backupOnce(this.mcpConfigPath);
|
|
162
172
|
const mcpBefore = fs.existsSync(this.mcpConfigPath) ? fs.readFileSync(this.mcpConfigPath, 'utf8') : '';
|
|
@@ -190,6 +200,9 @@ export class CursorHarness extends Harness {
|
|
|
190
200
|
verify: (doc) => hookEntries.every((e) => (doc?.hooks?.[e.path[1]] ?? []).some((el) => el?.command === e.match)),
|
|
191
201
|
refuseDetail: 'the three owned oathe hook entries',
|
|
192
202
|
});
|
|
203
|
+
// ONE row per file (review F1-class): the detail carries the vintage's match strings, so
|
|
204
|
+
// an address change would otherwise mint a second row beside the stale one.
|
|
205
|
+
manifest.removeWhere((r) => r.harness === this.name && r.file === this.hooksConfigPath && r.kind === 'json-array');
|
|
193
206
|
manifest.upsert({
|
|
194
207
|
harness: this.name,
|
|
195
208
|
file: this.hooksConfigPath,
|
|
@@ -209,7 +222,7 @@ export class CursorHarness extends Harness {
|
|
|
209
222
|
}
|
|
210
223
|
|
|
211
224
|
offboard({ manifest }) {
|
|
212
|
-
const rows =
|
|
225
|
+
const rows = this.takeWiringRows(manifest);
|
|
213
226
|
const actions = [];
|
|
214
227
|
for (const row of rows) {
|
|
215
228
|
if (!fs.existsSync(row.file)) {
|
|
@@ -52,19 +52,36 @@ export class Harness {
|
|
|
52
52
|
static launch = null;
|
|
53
53
|
/** {store, newest, projector, ownsPath} — the session-record store the verifier and doctor read. */
|
|
54
54
|
static traces = null;
|
|
55
|
-
/** {ownsExec, name} — recognizing this harness's session PROCESSES (exec
|
|
56
|
-
* NAMING the surface they speak from over facts (exec + nearest app bundle)
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
/** {ownsExec, name, display, resumable} — recognizing this harness's session PROCESSES (exec
|
|
56
|
+
* predicate), NAMING the surface they speak from over facts (exec + nearest app bundle),
|
|
57
|
+
* the WORD each named surface wears where work lives (`display: {surface: word}`), and
|
|
58
|
+
* which surfaces are apps the glass resumes INTO by opening them (`resumable`, ruling
|
|
59
|
+
* 2026-09-05 — a folder's session is never one). Facts are recorded at SessionStart;
|
|
60
|
+
* naming happens at READ, so it evolves without rewriting history. null: no local process
|
|
61
|
+
* of ours to meet in an ancestry walk. */
|
|
59
62
|
static surfaces = null;
|
|
63
|
+
/** Attestation (ruling 2026-09-04) — per owned surface NAME: 'hooks' when the harness's
|
|
64
|
+
* sessions register through the lifecycle hooks (a claim with no registered session is
|
|
65
|
+
* refused), 'hookless' when the surface never runs hooks by design (the claim is admitted
|
|
66
|
+
* and its evidence is discovered). A surface that never speaks declares null. */
|
|
67
|
+
static attestation = null;
|
|
68
|
+
/** The blocking exchange declared to the transport (ruling 2026-09-05): `{key, unit: 'sec'}` —
|
|
69
|
+
* the per-tool timeout KEY this adapter's MCP registration writes where its client reads it,
|
|
70
|
+
* valued from config `mcpToolTimeoutSec` (a `done` waits minutes for its verdict; codex's
|
|
71
|
+
* default was 60s). null when the client needs none (Claude Code: ≈28h default, and a call
|
|
72
|
+
* past two minutes becomes a background task) or documents none (Cursor). */
|
|
73
|
+
static mcpToolTimeout = null;
|
|
60
74
|
|
|
61
75
|
/**
|
|
62
76
|
* @param {{name?: string, home: string, envPath?: string, paths: object,
|
|
63
|
-
* exec?: {run: (cmd: string, args: string[]) => {status: number, stdout: string, stderr: string}}
|
|
77
|
+
* exec?: {run: (cmd: string, args: string[]) => {status: number, stdout: string, stderr: string}},
|
|
78
|
+
* config?: {get: Function}|null}} o config — the OatheConfig an adapter's writes are
|
|
79
|
+
* valued from (the codex timeout budget); null for read-only uses (detect, census)
|
|
64
80
|
*/
|
|
65
|
-
constructor({ name, home, envPath = process.env.PATH ?? '', paths, exec = defaultExec }) {
|
|
81
|
+
constructor({ name, home, envPath = process.env.PATH ?? '', paths, exec = defaultExec, config = null }) {
|
|
66
82
|
this.name = name ?? this.constructor.harnessName;
|
|
67
83
|
this.home = home;
|
|
84
|
+
this.config = config;
|
|
68
85
|
this.envPath = envPath;
|
|
69
86
|
this.paths = paths;
|
|
70
87
|
this.exec = exec;
|
|
@@ -82,6 +99,12 @@ export class Harness {
|
|
|
82
99
|
* them here; the resolver derives the fact once and every surface threads it.
|
|
83
100
|
* @param {{dir: string, home: string}} _o
|
|
84
101
|
*/
|
|
102
|
+
/** `{dirs(home), originators}` — the staging dirs an app surface runs sessions from (no project
|
|
103
|
+
* folder; a measured list, absolute paths for `home`) and the rollout originators that name the
|
|
104
|
+
* desktop (so `traces.stagingDrift` can say when the app moves). A claim from a staging dir is
|
|
105
|
+
* picked up by the app and says so in its place statement. null when none. */
|
|
106
|
+
static synthetic = null;
|
|
107
|
+
|
|
85
108
|
static isSyntheticWorkspaceDir(_o) {
|
|
86
109
|
return false;
|
|
87
110
|
}
|
|
@@ -108,7 +131,10 @@ export class Harness {
|
|
|
108
131
|
* How a fresh Linux runner gets this harness's REAL CLI — the install-contract lane installs
|
|
109
132
|
* it and proves `oathe init` against it: `{ npm, bin, versionArgs }` for an npm package,
|
|
110
133
|
* `{ installer, bin, versionArgs }` for a vendor install script, null when the harness has no
|
|
111
|
-
* CLI to install (its wiring is then our own file writes, pinned by the suite).
|
|
134
|
+
* CLI to install (its wiring is then our own file writes, pinned by the suite). `update`
|
|
135
|
+
* (ruling 2026-09-05): `(address) => [bin, args]` — the CLI's OWN in-place updater, run by
|
|
136
|
+
* `oathe engine update` when a judgment named it out of date; null when the adapter knows no
|
|
137
|
+
* updater (then the glass offers no update act and the stall words stay honest).
|
|
112
138
|
*/
|
|
113
139
|
static install = null;
|
|
114
140
|
|
|
@@ -117,6 +143,9 @@ export class Harness {
|
|
|
117
143
|
* REAL session fire our hooks and leave a transcript: `{ auth, command, extract }` — the env
|
|
118
144
|
* vars its non-interactive mode authenticates with (pinned from the docs snapshot), the
|
|
119
145
|
* argv for a prompt, and the extraction of the model's text from stdout; null for none.
|
|
146
|
+
* `diagnose(stderrTail) → 'outdated' | null` (ruling 2026-09-05): the ONLY reader of the
|
|
147
|
+
* engine's own failure words — the verifier records the cause, the pager words it, the glass
|
|
148
|
+
* acts on it. When the CLI changes its message, this predicate changes and nothing else does.
|
|
120
149
|
*/
|
|
121
150
|
static headless = null;
|
|
122
151
|
|
|
@@ -171,10 +200,48 @@ export class Harness {
|
|
|
171
200
|
return presence.cli && presence.configHome !== null;
|
|
172
201
|
}
|
|
173
202
|
|
|
203
|
+
/**
|
|
204
|
+
* The ONE resolver of a CLI's ADDRESS (ruling 2026-09-05, engines are addresses): the first
|
|
205
|
+
* executable named `name` on `envPath`, absolute, or null. Detection, the launcher and the
|
|
206
|
+
* engine runner all ask this — no second reading of PATH anywhere.
|
|
207
|
+
*/
|
|
208
|
+
static resolveOnPath(envPath, name) {
|
|
209
|
+
for (const dir of String(envPath ?? '').split(':').filter(Boolean)) {
|
|
210
|
+
const candidate = path.join(dir, name);
|
|
211
|
+
try { fs.accessSync(candidate, fs.constants.X_OK); return candidate; } catch { /* keep looking */ }
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
|
|
174
216
|
binOnPath(bin) {
|
|
175
|
-
return this.envPath
|
|
176
|
-
|
|
177
|
-
|
|
217
|
+
return Harness.resolveOnPath(this.envPath, bin) !== null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** The manifest kind that records a CLI's address — the one kind whose file oathe does not own. */
|
|
221
|
+
static CLI_ADDRESS_KIND = 'cli-address';
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* offboard()'s first line: take this harness's WIRING rows off the manifest — never its
|
|
225
|
+
* cli-address row, which records a file the harness owns (uninstall forgets it separately;
|
|
226
|
+
* an unwire keeps it: the CLI is still there to verify with).
|
|
227
|
+
*/
|
|
228
|
+
takeWiringRows(manifest) {
|
|
229
|
+
return manifest.removeWhere((r) => r.harness === this.name && r.kind !== Harness.CLI_ADDRESS_KIND);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Record WHERE this harness's CLI is (init, every run): one `cli-address` manifest row with the
|
|
234
|
+
* measured address, no sha (the file is the harness's, never ours — the doctor proves it RUNS
|
|
235
|
+
* under the LaunchAgent's PATH instead). Not found → no row, and any stale row goes: a
|
|
236
|
+
* daemon-forwarded judgment must never spawn a bare name into launchd's PATH again.
|
|
237
|
+
* @returns {Array<{action: string, file?: string}>}
|
|
238
|
+
*/
|
|
239
|
+
recordCliAddress({ manifest, version }) {
|
|
240
|
+
const { cliPath } = this.detect().presence;
|
|
241
|
+
const stale = manifest.removeWhere((r) => r.kind === Harness.CLI_ADDRESS_KIND && r.harness === this.name);
|
|
242
|
+
if (cliPath === null) return stale.length > 0 ? [{ action: 'cli-address-gone', file: stale[0].file }] : [];
|
|
243
|
+
manifest.upsert({ harness: this.name, file: cliPath, kind: Harness.CLI_ADDRESS_KIND, detail: { bin: path.basename(cliPath) }, blockVersion: version, sha256: null });
|
|
244
|
+
return [{ action: stale.some((r) => r.file === cliPath) ? 'cli-address-current' : 'cli-address-recorded', file: cliPath }];
|
|
178
245
|
}
|
|
179
246
|
|
|
180
247
|
/**
|
|
@@ -182,12 +249,14 @@ export class Harness {
|
|
|
182
249
|
* question does not apply), the CLI, the config home — and the adapter's own verdict on
|
|
183
250
|
* "installed" over those facts. Consumers pick the fact their capability needs (a headless
|
|
184
251
|
* run needs `cli`; wiring needs `configHome`), never the one bit.
|
|
185
|
-
*
|
|
252
|
+
* `cliPath` is the CLI's measured ADDRESS (the first cliBin resolved on this harness's PATH)
|
|
253
|
+
* or null; `cli` is its boolean face.
|
|
254
|
+
* @returns {{name: string, presence: {app: boolean|null, cli: boolean, cliPath: string|null, configHome: string|null}, installed: boolean}}
|
|
186
255
|
*/
|
|
187
256
|
detect() {
|
|
188
|
-
const
|
|
257
|
+
const cliPath = this.constructor.cliBins.map((bin) => Harness.resolveOnPath(this.envPath, bin)).find((p) => p !== null) ?? null;
|
|
189
258
|
const configHome = fs.existsSync(this.configHome) ? this.configHome : null;
|
|
190
|
-
const presence = { app: null, cli, configHome };
|
|
259
|
+
const presence = { app: null, cli: cliPath !== null, cliPath, configHome };
|
|
191
260
|
return { name: this.name, presence, installed: this.constructor.installedFrom(presence) };
|
|
192
261
|
}
|
|
193
262
|
|
|
@@ -39,7 +39,7 @@ export class CoworkSurface extends Harness {
|
|
|
39
39
|
detect() {
|
|
40
40
|
const appSupport = path.join(this.home, 'Library/Application Support/Claude');
|
|
41
41
|
const app = this.platform === 'darwin' && (fs.existsSync('/Applications/Claude.app') || fs.existsSync(appSupport));
|
|
42
|
-
const presence = { app, cli: false, configHome: app ? appSupport : null };
|
|
42
|
+
const presence = { app, cli: false, cliPath: null, configHome: app ? appSupport : null };
|
|
43
43
|
return { name: this.name, presence, installed: this.constructor.installedFrom(presence) };
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -65,7 +65,7 @@ export class ChatGptWebSurface extends Harness {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
detect() {
|
|
68
|
-
const presence = { app: null, cli: false, configHome: null };
|
|
68
|
+
const presence = { app: null, cli: false, cliPath: null, configHome: null };
|
|
69
69
|
return { name: this.name, presence, installed: false };
|
|
70
70
|
}
|
|
71
71
|
}
|
package/src/home.mjs
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
// oathe —
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// oathe — where work lives (founder ruling 2026-09-05, superseding R-HOME-BOARD's fixed home).
|
|
2
|
+
// A PLACE is where a claim was picked up — a folder (a workspace ref) or an app (a surface with
|
|
3
|
+
// no folder, the ChatGPT desktop) — and every pickup records its place as a statement
|
|
4
|
+
// (statements.mjs linkPlace). A task is VISIBLE on the board of every place that ever picked it
|
|
5
|
+
// up (the history keeps the visibility R-HOME-BOARD's fixed home once protected), and it
|
|
6
|
+
// RESIDES where it was picked up last: that is where continue goes, where the verifier runs,
|
|
7
|
+
// and the word a row wears. A claim is picked up at a place or it is refused; a task no claim
|
|
8
|
+
// has picked up is UNCLAIMED. There is no third word. No rank, no adoption — the last pickup.
|
|
6
9
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
10
|
+
// Residence and places are DERIVED, never stored: the DDL is frozen, and a stored copy would
|
|
11
|
+
// drift from the record it summarizes. This module is the ONE owner of two grammars, in
|
|
12
|
+
// JavaScript and in SQL: the ledger's contract_ref (`workspace:<ws-ref|none>;contract:<org>/
|
|
13
|
+
// <task>@v1` — the substrate's own field, transcribed by 016/027; `none` says "this claim had
|
|
14
|
+
// no folder", which is an app pickup) and the place (`workspace:<ws-ref>` | `app:<surface>`).
|
|
15
|
+
// Nothing else in the tree builds, parses, or pattern-matches either.
|
|
11
16
|
|
|
12
17
|
import { VERIFICATION_PREFIX, verifiedTaskId } from './plans.mjs';
|
|
18
|
+
import { PLACE_SUBJECT_PREFIX } from './statements.mjs';
|
|
13
19
|
|
|
14
|
-
/** The
|
|
15
|
-
export const
|
|
20
|
+
/** The ledger's token for a claim made from no folder (an app pickup) — a real ref is always `ws-<12hex>`, never this. */
|
|
21
|
+
export const NO_FOLDER = 'none';
|
|
16
22
|
|
|
17
23
|
const CONTRACT_VERSION = 'v1';
|
|
18
24
|
const GRAMMAR = /^workspace:([^;]+);contract:([^/]+)\/(.+)@v1$/;
|
|
25
|
+
const PLACE_GRAMMAR = /^(workspace|app):(.+)$/;
|
|
19
26
|
|
|
20
27
|
export class HomeError extends Error {
|
|
21
28
|
constructor(code, message, details = {}) {
|
|
@@ -26,7 +33,7 @@ export class HomeError extends Error {
|
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
/** A claim's contract reference: the
|
|
36
|
+
/** A claim's contract reference: the folder it was made from (null = none) + the contract. */
|
|
30
37
|
export class ContractRef {
|
|
31
38
|
/** @param {{workspace: string|null, orgId: string, taskId: string}} o */
|
|
32
39
|
constructor({ workspace, orgId, taskId }) {
|
|
@@ -40,68 +47,183 @@ export class ContractRef {
|
|
|
40
47
|
const match = GRAMMAR.exec(String(text));
|
|
41
48
|
if (!match) {
|
|
42
49
|
throw new HomeError('OATHE_CONTRACT_REF_MALFORMED',
|
|
43
|
-
`contract_ref '${text}' does not follow workspace:<ws|${
|
|
50
|
+
`contract_ref '${text}' does not follow workspace:<ws|${NO_FOLDER}>;contract:<org>/<task>@${CONTRACT_VERSION}`,
|
|
44
51
|
{ text });
|
|
45
52
|
}
|
|
46
53
|
const [, workspace, orgId, taskId] = match;
|
|
47
|
-
return new ContractRef({ workspace: workspace ===
|
|
54
|
+
return new ContractRef({ workspace: workspace === NO_FOLDER ? null : workspace, orgId, taskId });
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
/** A folder claim; false for an app pickup (the ledger's `none`). */
|
|
58
|
+
get hasFolder() {
|
|
59
|
+
return this.workspace !== null;
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
toString() {
|
|
55
|
-
return `workspace:${this.workspace ??
|
|
63
|
+
return `workspace:${this.workspace ?? NO_FOLDER};contract:${this.orgId}/${this.taskId}@${CONTRACT_VERSION}`;
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
68
|
+
* Where a claim was picked up: a folder (`workspace:<ws-ref>`) or an app (`app:<surface>` —
|
|
69
|
+
* the surface name the adapter gives it, e.g. `chatgpt`). A value object; the statement's
|
|
70
|
+
* subject is `place:` + this string (statements.mjs owns the subject prefix).
|
|
62
71
|
*/
|
|
63
|
-
export class
|
|
64
|
-
/** @param {{
|
|
65
|
-
constructor({
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
72
|
+
export class Place {
|
|
73
|
+
/** @param {{kind: 'workspace'|'app', ref: string}} o */
|
|
74
|
+
constructor({ kind, ref }) {
|
|
75
|
+
this.kind = kind;
|
|
76
|
+
this.ref = ref;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static workspace(ref) {
|
|
80
|
+
return new Place({ kind: 'workspace', ref });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static app(surface) {
|
|
84
|
+
return new Place({ kind: 'app', ref: surface });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** @throws {HomeError} OATHE_PLACE_MALFORMED — a place is a folder ref or an app surface, never the ledger's token */
|
|
88
|
+
static parse(text) {
|
|
89
|
+
const match = PLACE_GRAMMAR.exec(String(text));
|
|
90
|
+
if (!match || (match[1] === 'workspace' && match[2] === NO_FOLDER)) {
|
|
91
|
+
throw new HomeError('OATHE_PLACE_MALFORMED',
|
|
92
|
+
`place '${text}' does not follow workspace:<ws-ref> | app:<surface>`, { text });
|
|
93
|
+
}
|
|
94
|
+
return new Place({ kind: match[1], ref: match[2] });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** A row that has no place is null — never a throw. */
|
|
98
|
+
static parseOrNull(text) {
|
|
99
|
+
return text === null || text === undefined ? null : Place.parse(text);
|
|
68
100
|
}
|
|
69
101
|
|
|
70
|
-
|
|
102
|
+
get isFolder() {
|
|
103
|
+
return this.kind === 'workspace';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
toString() {
|
|
107
|
+
return `${this.kind}:${this.ref}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* What a pickup KNOWS beside its place, each only when known: the app bundle it was spoken from,
|
|
113
|
+
* the device, and — for an app pickup — the project folder the app ran in (the ChatGPT project's
|
|
114
|
+
* staging dir, where its files are; never a place to resume into). One grammar (`app:`,
|
|
115
|
+
* `device:`, `dir:`), one writer, one parser; a row reads it back as place_app/place_device/place_dir.
|
|
116
|
+
*/
|
|
117
|
+
const EVIDENCE_PREFIX = Object.freeze({ app: 'app:', device: 'device:', dir: 'dir:' });
|
|
118
|
+
|
|
119
|
+
export class PlaceEvidence {
|
|
120
|
+
/** @param {{app?: string|null, device?: string|null, dir?: string|null}} o */
|
|
121
|
+
constructor({ app = null, device = null, dir = null } = {}) {
|
|
122
|
+
this.app = app;
|
|
123
|
+
this.device = device;
|
|
124
|
+
this.dir = dir;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The evidence refs a place statement carries — the known facts only, never a null string. */
|
|
128
|
+
get refs() {
|
|
129
|
+
return Object.entries(EVIDENCE_PREFIX).flatMap(([key, prefix]) => (this[key] ? [`${prefix}${this[key]}`] : []));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The refs of a place statement back to facts; refs of another grammar are ignored. */
|
|
133
|
+
static parse(refs) {
|
|
134
|
+
const list = Array.isArray(refs) ? refs : [];
|
|
135
|
+
const pick = (prefix) => list.find((r) => typeof r === 'string' && r.startsWith(prefix))?.slice(prefix.length) ?? null;
|
|
136
|
+
return new PlaceEvidence({ app: pick(EVIDENCE_PREFIX.app), device: pick(EVIDENCE_PREFIX.device), dir: pick(EVIDENCE_PREFIX.dir) });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The row shape every surface reads (the pager, the board, the glass). */
|
|
140
|
+
row() {
|
|
141
|
+
return { place_app: this.app, place_device: this.device, place_dir: this.dir };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The PICKUP: where a surface picks work up and what it knows — computed once per surface, recorded
|
|
147
|
+
* on every claim and re-seat (ruling 2026-09-05). A folder session picks up at its workspace (the
|
|
148
|
+
* folder is the registry's fact, not evidence); an app session (a synthetic dir, or no folder at
|
|
149
|
+
* all) picks up at `app:<surface>` and records the project dir it ran in; a surface with neither
|
|
150
|
+
* has no place, and `require()` refuses a claim from it. A system task (a judgment, an update)
|
|
151
|
+
* never records a place: it lives where its work does.
|
|
152
|
+
*/
|
|
153
|
+
export class Pickup {
|
|
154
|
+
/** @param {{place: Place|null, evidence: PlaceEvidence}} o */
|
|
155
|
+
constructor({ place, evidence }) {
|
|
156
|
+
this.place = place;
|
|
157
|
+
this.evidence = evidence;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static of({ workspace = null, synthetic = false, dir = null, speaker = null } = {}) {
|
|
161
|
+
const folder = !synthetic && workspace ? Place.workspace(workspace) : null;
|
|
162
|
+
const app = folder === null && speaker?.surface ? Place.app(speaker.surface) : null;
|
|
163
|
+
return new Pickup({
|
|
164
|
+
place: folder ?? app,
|
|
165
|
+
evidence: new PlaceEvidence({ app: speaker?.app?.bundle ?? null, device: speaker?.device ?? null, dir: app !== null ? dir : null }),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** @throws {HomeError} OATHE_PLACE_UNKNOWN — a claim is picked up somewhere, or it is refused before anything is written */
|
|
170
|
+
require(taskId) {
|
|
171
|
+
if (this.place === null) {
|
|
172
|
+
throw new HomeError('OATHE_PLACE_UNKNOWN',
|
|
173
|
+
`a claim is picked up somewhere — a folder session or an app — and this surface named neither; `
|
|
174
|
+
+ `speak it from a harness session on a project folder or from the desktop app (task '${taskId}')`, { task_id: taskId });
|
|
175
|
+
}
|
|
176
|
+
return this.place;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The place rule projected into SQL so the board, the pager, and the verifier never
|
|
182
|
+
* re-implement it: `residenceSql` is the LAST pickup (a LATERAL body yielding `place` and
|
|
183
|
+
* `place_evidence`), `placesSql` every pickup (a scalar text[] of place strings). Both anchor
|
|
184
|
+
* a verification task on its parent — the judgment lives where the work does.
|
|
185
|
+
*
|
|
186
|
+
* A pickup is read from ONE record: the place statement every claim records at the pickup
|
|
187
|
+
* (statements.mjs linkPlace). The ledger's `contract_ref` slot still carries the claim's folder
|
|
188
|
+
* (or `none`) because the substrate's verbs transcribe it, but nothing derives a place from it —
|
|
189
|
+
* a claim with no place statement does not exist (zero legacy, founder 2026-09-05: records from
|
|
190
|
+
* before the statement were removed from the machine, never inferred).
|
|
191
|
+
*/
|
|
192
|
+
export class HomeBoard {
|
|
193
|
+
/** The task whose record decides `taskId`'s place: itself, or its parent for a verification task. */
|
|
71
194
|
static anchorTaskId(taskId) {
|
|
72
195
|
return verifiedTaskId(taskId) ?? taskId;
|
|
73
196
|
}
|
|
74
197
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
198
|
+
static #anchorSql(t) {
|
|
199
|
+
return `CASE WHEN ${t}.task_id LIKE '${VERIFICATION_PREFIX}%'
|
|
200
|
+
THEN substr(${t}.task_id, ${VERIFICATION_PREFIX.length + 1})
|
|
201
|
+
ELSE ${t}.task_id END`;
|
|
78
202
|
}
|
|
79
203
|
|
|
80
204
|
/**
|
|
81
|
-
*
|
|
82
|
-
* The
|
|
83
|
-
*
|
|
205
|
+
* Every pickup of the anchored task — the place statements, and nothing else (place,
|
|
206
|
+
* place_evidence, at). The ledger's `contract_ref` slot is NOT read as a pickup: every claim
|
|
207
|
+
* records its place as a statement at the pickup, and a claim without one does not exist
|
|
208
|
+
* (zero legacy, founder 2026-09-05 — records from before the statement were removed, never inferred).
|
|
84
209
|
*/
|
|
85
|
-
static
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ORDER BY claimed_at ASC LIMIT 1`,
|
|
104
|
-
[this.orgId, HomeBoard.anchorTaskId(taskId), HomeBoard.homelessPattern]);
|
|
105
|
-
return rows[0]?.workspace ?? null;
|
|
210
|
+
static #pickupsSql(t) {
|
|
211
|
+
return `SELECT substr(s.subject_ref, ${PLACE_SUBJECT_PREFIX.length + 1}) AS place, s.evidence_refs AS place_evidence, s.asserted_at AS at
|
|
212
|
+
FROM cell.agent_statement s
|
|
213
|
+
WHERE s.org_id = ${t}.org_id AND s.task_id = ${HomeBoard.#anchorSql(t)}
|
|
214
|
+
AND s.subject_ref LIKE '${PLACE_SUBJECT_PREFIX}%'`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** LATERAL body: the residence — the latest pickup's place text and its evidence (app, device). */
|
|
218
|
+
static residenceSql(taskAlias) {
|
|
219
|
+
return `SELECT pickup.place, pickup.place_evidence
|
|
220
|
+
FROM (${HomeBoard.#pickupsSql(taskAlias)}) pickup
|
|
221
|
+
ORDER BY pickup.at DESC LIMIT 1`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Scalar subquery: every place that ever picked the task up, as place strings (text[], never NULL). */
|
|
225
|
+
static placesSql(taskAlias) {
|
|
226
|
+
return `(SELECT coalesce(array_agg(DISTINCT pickup.place), '{}'::text[])
|
|
227
|
+
FROM (${HomeBoard.#pickupsSql(taskAlias)}) pickup)`;
|
|
106
228
|
}
|
|
107
229
|
}
|
package/src/init.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export async function runInit({
|
|
|
33
33
|
// 2026-08-29).
|
|
34
34
|
const machine = OatheConfig.global({ env: ctx.config.env });
|
|
35
35
|
// DECLARATIVE: the screen shows the wiring state and Enter makes the machine match it.
|
|
36
|
-
const wiredNow = new Set(
|
|
36
|
+
const wiredNow = new Set(wired.map((a) => a.name).filter((h) => manifest.wiringRowsFor(h).length > 0));
|
|
37
37
|
const plan = SetupPlan.from({
|
|
38
38
|
adapters: wired, census: seen, surfaces, machine, home: ctx.home, paths: ctx.paths, fallbackVerifier: ctx.config.get('verifier'), wiredNow,
|
|
39
39
|
});
|
|
@@ -124,6 +124,24 @@ export async function runInit({
|
|
|
124
124
|
actions.push({ harness: name, ...action });
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
// The shim FIRST: every adapter's wiring, the plugin's hooks, and the notch-frame acts
|
|
128
|
+
// address $HOME/.oathe/bin/oathe — the one durable address (connection-lane plan,
|
|
129
|
+
// 2026-09-04). Re-stamped every init, so node moves never strand a harness config.
|
|
130
|
+
const { writeShim } = await import('./shim.mjs');
|
|
131
|
+
for (const action of writeShim({ home: ctx.home, manifest, version, packageRoot: ctx.paths.packageRoot })) {
|
|
132
|
+
actions.push({ harness: 'shim', ...action });
|
|
133
|
+
}
|
|
134
|
+
// The device identity (ruling 2026-09-04): minted once, kept forever, one row — the
|
|
135
|
+
// trust unit anything outside this machine will sign against (src/device.mjs).
|
|
136
|
+
const { writeDevice } = await import('./device.mjs');
|
|
137
|
+
const [deviceAction] = writeDevice({ devicePath: ctx.paths.devicePath, manifest, version });
|
|
138
|
+
actions.push({ harness: 'device', ...deviceAction });
|
|
139
|
+
// Every harness's CLI ADDRESS (ruling 2026-09-05: engines are addresses, never recipes): a
|
|
140
|
+
// machine fact recorded whether or not the harness is wired — the verifier can be any CLI
|
|
141
|
+
// here — so a judgment spawned from launchd's bare PATH (the feed, the daemon) still finds it.
|
|
142
|
+
for (const harness of wired) {
|
|
143
|
+
for (const action of harness.recordCliAddress({ manifest, version })) actions.push({ harness: harness.name, ...action });
|
|
144
|
+
}
|
|
127
145
|
for (const step of plan.steps) {
|
|
128
146
|
if (!step.installed) {
|
|
129
147
|
actions.push({ harness: step.name, action: 'skipped-not-installed' });
|
|
@@ -144,6 +162,12 @@ export async function runInit({
|
|
|
144
162
|
for (const action of wireNotch({ home: ctx.home, manifest, config: ctx.config, version, packageRoot: ctx.paths.packageRoot, ...(exec ? { exec } : {}) })) {
|
|
145
163
|
actions.push({ harness: 'notch', ...action });
|
|
146
164
|
}
|
|
165
|
+
// The serve daemon (connection-lane phase 2): launchd runs the shim written above; every
|
|
166
|
+
// `oathe mcp` forwards to it when it answers, and the device holds ONE substrate presence.
|
|
167
|
+
const { wireServe } = await import('./serve.mjs');
|
|
168
|
+
for (const action of wireServe({ home: ctx.home, manifest, config: ctx.config, version, ...(exec ? { exec } : {}) })) {
|
|
169
|
+
actions.push({ harness: 'serve', ...action });
|
|
170
|
+
}
|
|
147
171
|
// This run took as long as its CLI calls did; a hook or a server may have saved a row in
|
|
148
172
|
// the meantime. Under the lock, merge what landed on disk, then record this run — never a
|
|
149
173
|
// snapshot over a living file (B4, 2026-09-03).
|
|
@@ -155,7 +179,8 @@ export async function runInit({
|
|
|
155
179
|
census: seen,
|
|
156
180
|
surfaces,
|
|
157
181
|
substrate: await substrate.status(),
|
|
158
|
-
|
|
182
|
+
device: { device_id: deviceAction.device_id, minted: deviceAction.action === 'device-minted' },
|
|
183
|
+
principal: { org_id: identity.orgId, principal_id: identity.principalId, role: 'ceo' },
|
|
159
184
|
verifier: { principal_id: verifierPrincipal, seats },
|
|
160
185
|
verifier_engine: {
|
|
161
186
|
chosen: v.chosen,
|