@oathe/oathe 0.0.1 → 0.2.1

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 (71) hide show
  1. package/.claude-plugin/marketplace.json +14 -0
  2. package/LICENSE +202 -21
  3. package/NOTICE +7 -0
  4. package/README.md +104 -12
  5. package/assets/oathe-hero.svg +92 -0
  6. package/bin/oathe.mjs +376 -0
  7. package/docs/PRIVACY.md +45 -0
  8. package/package.json +33 -23
  9. package/plugin/.claude-plugin/plugin.json +10 -0
  10. package/plugin/.mcp.json +13 -0
  11. package/plugin/hooks/frame-note.mjs +24 -0
  12. package/plugin/hooks/heartbeat.mjs +49 -0
  13. package/plugin/hooks/hooks.json +39 -0
  14. package/plugin/hooks/lib.mjs +83 -0
  15. package/plugin/hooks/render-board.mjs +11 -0
  16. package/plugin/skills/oathe-work/SKILL.md +33 -0
  17. package/src/atif.mjs +633 -0
  18. package/src/blocks.mjs +192 -0
  19. package/src/board-render.mjs +106 -0
  20. package/src/config.mjs +169 -0
  21. package/src/context.mjs +35 -0
  22. package/src/doctor.mjs +108 -0
  23. package/src/harness.mjs +271 -0
  24. package/src/init.mjs +92 -0
  25. package/src/launch-env.mjs +25 -0
  26. package/src/launch.mjs +259 -0
  27. package/src/manifest.mjs +89 -0
  28. package/src/mcp/oathe-tools.mjs +517 -0
  29. package/src/paths.mjs +49 -0
  30. package/src/plans.mjs +50 -0
  31. package/src/runtime/discharge.mjs +57 -0
  32. package/src/runtime/provider.mjs +154 -0
  33. package/src/runtime/simple-cage.mjs +67 -0
  34. package/src/runtime/sql-acceptance-lane.mjs +89 -0
  35. package/src/session-host.mjs +81 -0
  36. package/src/substrate.mjs +337 -0
  37. package/src/successor.mjs +31 -0
  38. package/src/traces.mjs +242 -0
  39. package/src/uninstall.mjs +45 -0
  40. package/src/verifier.mjs +322 -0
  41. package/src/workspace.mjs +47 -0
  42. package/vendor/ddl/001_core.sql +312 -0
  43. package/vendor/ddl/002_claim.sql +438 -0
  44. package/vendor/ddl/003_verification.sql +480 -0
  45. package/vendor/ddl/004_delegation.sql +397 -0
  46. package/vendor/ddl/005_escalation.sql +303 -0
  47. package/vendor/ddl/006_dependency.sql +384 -0
  48. package/vendor/ddl/007_assignment.sql +502 -0
  49. package/vendor/ddl/008_effect_receipt.sql +290 -0
  50. package/vendor/ddl/009_verified_edge.sql +452 -0
  51. package/vendor/ddl/010_parent_child_verification.sql +320 -0
  52. package/vendor/ddl/011_confirm.sql +288 -0
  53. package/vendor/ddl/012_evaluator_lane.sql +444 -0
  54. package/vendor/ddl/013_claim_terminal.sql +279 -0
  55. package/vendor/ddl/014_claim_settlement.sql +327 -0
  56. package/vendor/ddl/015_claim_yield.sql +213 -0
  57. package/vendor/ddl/016_reopened_reclaim.sql +285 -0
  58. package/vendor/ddl/017_claim_yield_causes.sql +357 -0
  59. package/vendor/ddl/018_receiptless_unknown.sql +249 -0
  60. package/vendor/ddl/019_verification_contract_freeze.sql +335 -0
  61. package/vendor/ddl/020_context_compilation.sql +105 -0
  62. package/vendor/ddl/021_execution_attempt_closure.sql +95 -0
  63. package/vendor/ddl/022_verification_clause.sql +106 -0
  64. package/vendor/ddl/023_executor_role.sql +66 -0
  65. package/vendor/ddl/024_executor_role_hardening.sql +439 -0
  66. package/vendor/ddl/025_running_attempt_uniqueness.sql +102 -0
  67. package/vendor/ddl/026_acceptance_authority.sql +230 -0
  68. package/vendor/ddl/027_ownership_return.sql +836 -0
  69. package/vendor/ddl/028_attempt_bind_ownership.sql +173 -0
  70. package/vendor/ddl/manifest.json +183 -0
  71. package/index.js +0 -33
package/bin/oathe.mjs ADDED
@@ -0,0 +1,376 @@
1
+ #!/usr/bin/env node
2
+ // oathe — the subcommand router. Deliberate divergence from the monorepo's env-only bins:
3
+ // oathe is a USER tool, so it speaks argv (node:util parseArgs); it keeps the estate's
4
+ // machine-parseable summary line (`oathe: <verb> <status>`) as the last line of every run.
5
+
6
+ import { parseArgs } from 'node:util';
7
+
8
+ const VERBS = ['init', 'claude', 'codex', 'claim', 'ls', 'note', 'done', 'verify', 'trace', 'yield', 'config', 'doctor', 'uninstall', 'status', 'hook', 'mcp'];
9
+
10
+ const USAGE = `usage: oathe <verb> [args]
11
+
12
+ verbs:
13
+ init onboard installed harnesses + bring up the local cell substrate
14
+ claude [--hermetic] [args…] launch interactive Claude Code inside the cage, board attached
15
+ codex [--hermetic] [args…] launch interactive Codex inside the cage, board attached
16
+ claim <task-id> [objective] claim a task (minting it when new — objective required then)
17
+ ls [--all] this workspace's board (--all: every workspace)
18
+ note <task-id> <text> [ref] record a progress statement against your active claim
19
+ done <task-id> <what> [ref] assert completion (a completion statement + the substrate's terminal)
20
+ verify [task] [--all] [--engine claude|codex] run the verification lane (non-author seat settles)
21
+ trace <task-id> [--out dir] export the claim's linked session traces as ATIF trajectories
22
+ yield <task-id> <note> yield: the task goes back on the board, unowned
23
+ doctor verify every managed surface against the install manifest
24
+ status the substrate half of doctor
25
+ config <key> [value] [--global] read or write a config key (workspace scope by default)
26
+ uninstall [--purge-db] remove exactly what init recorded (the database stays put)
27
+ hook <name> · mcp internal: the plugin's hook/server entry points (bin-addressed)
28
+ `;
29
+
30
+ function summary(verb, status) {
31
+ process.stdout.write(`oathe: ${verb} ${status}\n`);
32
+ }
33
+
34
+ function fail(verb, e) {
35
+ process.stderr.write(`${e?.code ? `[${e.code}] ` : ''}${e?.message || e}\n`);
36
+ const status = /refus|REFUSED|already|second|active claim/i.test(String(e?.message)) ? 'refused' : 'error';
37
+ process.stderr.write(`oathe: ${verb} ${status}\n`);
38
+ process.exit(1);
39
+ }
40
+
41
+ async function toolsForCwd(env = process.env) {
42
+ const [{ buildContext }, { createOatheTools }, { workspaceRef }] = await Promise.all([
43
+ import('../src/context.mjs'), import('../src/mcp/oathe-tools.mjs'), import('../src/workspace.mjs'),
44
+ ]);
45
+ const ctx = buildContext({ env });
46
+ return {
47
+ ctx,
48
+ tools: createOatheTools({
49
+ client: ctx.substrate,
50
+ identity: ctx.identity,
51
+ config: ctx.config,
52
+ workspace: workspaceRef(process.cwd()),
53
+ }),
54
+ };
55
+ }
56
+
57
+ const handlers = {
58
+ async init() {
59
+ const { runInit } = await import('../src/init.mjs');
60
+ const result = await runInit({});
61
+ process.stdout.write('harness census:\n');
62
+ for (const c of result.census) {
63
+ process.stdout.write(` ${c.name.padEnd(8)} ${c.installed ? 'onboarded' : 'not installed — skipped'}\n`);
64
+ }
65
+ const s = result.substrate;
66
+ process.stdout.write(`substrate: db up, ddl ${s.ddl_applied}/${s.ddl_expected} applied `
67
+ + `(source: ${s.ddl_source}), yield cause ${s.yield_cause_registered ? 'registered' : 'MISSING'}\n`);
68
+ process.stdout.write(`principal: ${result.principal.principal_id} (${result.principal.role})\n`);
69
+ for (const a of result.actions) {
70
+ process.stdout.write(` ${a.harness.padEnd(8)} ${a.action}\n`);
71
+ }
72
+ summary('init', 'ok');
73
+ },
74
+
75
+ async claude(argv) {
76
+ return launchHarness('claude', argv);
77
+ },
78
+
79
+ async codex(argv) {
80
+ return launchHarness('codex', argv);
81
+ },
82
+
83
+ async hook(argv) {
84
+ const scripts = {
85
+ 'render-board': 'render-board.mjs', heartbeat: 'heartbeat.mjs', 'frame-note': 'frame-note.mjs',
86
+ };
87
+ const script = scripts[argv[0]];
88
+ if (!script) throw new Error(`usage: oathe hook <${Object.keys(scripts).join('|')}>`);
89
+ const { buildPaths } = await import('../src/paths.mjs');
90
+ // The hook module runs on import (reads stdin, writes its frame, exits 0 itself).
91
+ await import(`${buildPaths(process.env).pluginDir}/hooks/${script}`);
92
+ },
93
+
94
+ async mcp() {
95
+ const { main } = await import('../src/mcp/oathe-tools.mjs');
96
+ await main();
97
+ },
98
+
99
+ async claim(argv) {
100
+ const [taskId, objective] = argv;
101
+ if (!taskId) throw new Error('usage: oathe claim <task-id> [objective]');
102
+ const { ctx, tools } = await toolsForCwd();
103
+ try {
104
+ const out = await tools.oathe_claim({ task_id: taskId, objective });
105
+ process.stdout.write(`claimed: ${out.task_id} (lease ${out.lease}) — ${out.note}\n`);
106
+ summary('claim', 'ok');
107
+ } finally {
108
+ await ctx.substrate.close();
109
+ }
110
+ },
111
+
112
+ async ls(argv) {
113
+ const { values } = parseArgs({
114
+ args: argv, options: { all: { type: 'boolean', default: false } }, allowPositionals: true,
115
+ });
116
+ const { ctx, tools } = await toolsForCwd();
117
+ try {
118
+ const { sections, workspace } = await tools.oathe_board({ all: values.all === true });
119
+ process.stdout.write(`board${workspace ? ` (${workspace})` : ' (all workspaces)'}:\n`);
120
+ const listed = [...sections.mine, ...sections.open, ...sections.asserted, ...sections.held];
121
+ if (listed.length === 0) process.stdout.write(' (none — a clean slate)\n');
122
+ for (const r of listed) {
123
+ const holder = r.state === 'active' ? `${r.principal_id}, lease until ${r.lease_until}` : (r.state ?? 'open');
124
+ process.stdout.write(` [${(r.state ?? 'open').padEnd(8)}] ${r.task_id} — ${r.objective} (${holder})\n`);
125
+ }
126
+ summary('ls', 'ok');
127
+ } finally {
128
+ await ctx.substrate.close();
129
+ }
130
+ },
131
+
132
+ async note(argv) {
133
+ const [taskId, proposition, evidenceRef] = argv;
134
+ if (!taskId || !proposition) throw new Error('usage: oathe note <task-id> <text> [evidence-ref]');
135
+ const { ctx, tools } = await toolsForCwd();
136
+ try {
137
+ const out = await tools.oathe_statement({ task_id: taskId, proposition, evidence_ref: evidenceRef });
138
+ process.stdout.write(`statement recorded (${out.note})\n`);
139
+ summary('note', 'ok');
140
+ } finally {
141
+ await ctx.substrate.close();
142
+ }
143
+ },
144
+
145
+ async done(argv) {
146
+ const [taskId, proposition, evidenceRef] = argv;
147
+ if (!taskId || !proposition) throw new Error('usage: oathe done <task-id> <what-was-done> [evidence-ref]');
148
+ const { ctx, tools } = await toolsForCwd();
149
+ try {
150
+ const out = await tools.oathe_done({ task_id: taskId, proposition, evidence_ref: evidenceRef });
151
+ process.stdout.write(`done: ${out.task_id} — ${out.note}\n`);
152
+ summary('done', 'ok');
153
+ } finally {
154
+ await ctx.substrate.close();
155
+ }
156
+ },
157
+
158
+ async verify(argv) {
159
+ const { values, positionals } = parseArgs({
160
+ args: argv,
161
+ options: { all: { type: 'boolean', default: false }, engine: { type: 'string' } },
162
+ allowPositionals: true,
163
+ });
164
+ const [{ buildContext }, { Verifier }, { workspaceRef }] = await Promise.all([
165
+ import('../src/context.mjs'), import('../src/verifier.mjs'), import('../src/workspace.mjs'),
166
+ ]);
167
+ const ctx = buildContext({});
168
+ const verifier = new Verifier({
169
+ substrate: ctx.substrate, paths: ctx.paths, config: ctx.config,
170
+ workspace: workspaceRef(process.cwd()),
171
+ operatorPrincipal: ctx.identity.principalId,
172
+ });
173
+ try {
174
+ const targets = values.all === true ? await verifier.pending() : [positionals[0]];
175
+ if (!targets[0]) throw new Error('usage: oathe verify <task-id> | --all');
176
+ let attention = false;
177
+ for (const target of targets) {
178
+ const out = await verifier.verify({ taskId: target, engine: values.engine });
179
+ const mark = out.verdict === 'accepted' ? '✓ settled' : '✗ rejected — task reopened';
180
+ process.stdout.write(`${out.task_id}: ${mark} (${out.engine}) — ${out.reason}\n`);
181
+ if (out.verdict !== 'accepted') attention = true;
182
+ }
183
+ summary('verify', attention ? 'attention' : 'ok');
184
+ } finally {
185
+ await verifier.close();
186
+ await ctx.substrate.close();
187
+ }
188
+ },
189
+
190
+ async trace(argv) {
191
+ const { values, positionals } = parseArgs({
192
+ args: argv, options: { out: { type: 'string' } }, allowPositionals: true,
193
+ });
194
+ const [taskId] = positionals;
195
+ if (!taskId) throw new Error('usage: oathe trace <task-id> [--out <dir>]');
196
+ const [{ buildContext }, { projectorFor }, { workspaceRef }, fs, path] = await Promise.all([
197
+ import('../src/context.mjs'), import('../src/atif.mjs'), import('../src/workspace.mjs'),
198
+ import('node:fs'), import('node:path'),
199
+ ]);
200
+ const ctx = buildContext({});
201
+ try {
202
+ const { rows: claims } = await ctx.substrate.query(
203
+ `SELECT work_claim_id, contract_ref FROM cell.work_claim
204
+ WHERE org_id = $1 AND task_id = $2 ORDER BY claimed_at DESC LIMIT 1`,
205
+ [ctx.identity.orgId, taskId]);
206
+ if (claims.length === 0) throw new Error(`no claim on '${taskId}' — nothing to trace`);
207
+ const claim = claims[0];
208
+ const { rows: traceRows } = await ctx.substrate.query(
209
+ `SELECT evidence_refs FROM cell.agent_statement
210
+ WHERE org_id = $1 AND work_claim_id = $2 AND subject_ref LIKE 'trace:%'`,
211
+ [ctx.identity.orgId, claim.work_claim_id]);
212
+ const { rows: verdicts } = await ctx.substrate.query(
213
+ `SELECT result, verifier_principal, verification_id FROM cell.verification
214
+ WHERE org_id = $1 AND task_id = $2 ORDER BY recorded_at DESC LIMIT 1`,
215
+ [ctx.identity.orgId, taskId]);
216
+ const files = traceRows.flatMap((r) => r.evidence_refs);
217
+ if (files.length === 0) throw new Error(`'${taskId}' has no linked traces — nothing to export`);
218
+ const trajectories = files.map((file) => {
219
+ const trajectory = projectorFor(file).project(file);
220
+ Object.assign(trajectory.extra.oathe, {
221
+ org_id: ctx.identity.orgId,
222
+ task_id: taskId,
223
+ work_claim_id: claim.work_claim_id,
224
+ contract_ref: claim.contract_ref,
225
+ workspace: workspaceRef(process.cwd()),
226
+ ...(verdicts[0] ? { verdict: verdicts[0] } : {}),
227
+ });
228
+ return trajectory;
229
+ });
230
+ if (values.out) {
231
+ fs.mkdirSync(values.out, { recursive: true });
232
+ for (const [at, trajectory] of trajectories.entries()) {
233
+ const file = path.join(values.out, `${taskId.replaceAll(/[^a-zA-Z0-9_-]/g, '_')}-${at + 1}.atif.json`);
234
+ fs.writeFileSync(file, `${JSON.stringify(trajectory, null, 2)}\n`);
235
+ process.stdout.write(`${file}\n`);
236
+ }
237
+ } else {
238
+ // stdout is PURE JSON here; the machine summary rides stderr instead.
239
+ process.stdout.write(`${JSON.stringify(trajectories, null, 2)}\n`);
240
+ }
241
+ process.stderr.write('oathe: trace ok\n');
242
+ } finally {
243
+ await ctx.substrate.close();
244
+ }
245
+ },
246
+
247
+ async yield(argv) {
248
+ const [taskId, note] = argv;
249
+ if (!taskId || !note) throw new Error('usage: oathe yield <task-id> <note>');
250
+ const { ctx, tools } = await toolsForCwd();
251
+ try {
252
+ const out = await tools.oathe_yield({ task_id: taskId, note });
253
+ process.stdout.write(`yielded: ${out.task_id} — ${out.note}\n`);
254
+ summary('yield', 'ok');
255
+ } finally {
256
+ await ctx.substrate.close();
257
+ }
258
+ },
259
+
260
+ async config(argv) {
261
+ const { values, positionals } = parseArgs({
262
+ args: argv, options: { global: { type: 'boolean', default: false } }, allowPositionals: true,
263
+ });
264
+ const [key, raw] = positionals;
265
+ if (!key) throw new Error('usage: oathe config <key> [value] [--global]');
266
+ const { OatheConfig, CONFIG_KEYS } = await import('../src/config.mjs');
267
+ const cfg = new OatheConfig({});
268
+ if (raw === undefined) {
269
+ process.stdout.write(`${key} = ${JSON.stringify(cfg.get(key)).replaceAll('"', '')}\n`);
270
+ } else {
271
+ const value = /^\d+$/.test(raw) ? Number(raw) : raw;
272
+ const out = cfg.set(key, value, { scope: values.global ? 'global' : 'workspace' });
273
+ process.stdout.write(`${key} = ${raw} (${out.file})\n`);
274
+ }
275
+ summary('config', 'ok');
276
+ },
277
+
278
+ async doctor() {
279
+ const { runDoctor } = await import('../src/doctor.mjs');
280
+ const result = await runDoctor({});
281
+ const s = result.substrate;
282
+ process.stdout.write(`substrate: ${s.reachable ? 'reachable' : 'UNREACHABLE'}, `
283
+ + `db ${s.database_exists ? 'present' : 'ABSENT'}, ddl ${s.ddl_applied}/${s.ddl_expected}, `
284
+ + `ddl source: ${s.ddl_source}, yield cause ${s.yield_cause_registered ? 'ok' : 'MISSING'}\n`);
285
+ process.stdout.write(`plugin: ${result.plugin.resolves ? 'resolves' : `BROKEN (${result.plugin.detail})`}\n`);
286
+ const rt = result.runtime;
287
+ process.stdout.write(!rt.provider
288
+ ? `runtime: UNRESOLVED (requested ${rt.requested}) — ${rt.error}\n`
289
+ : rt.probe && !rt.probe.ok
290
+ ? `runtime: ${rt.provider} (requested ${rt.requested}) — UNLINKED: run npm run link-runtime\n`
291
+ : `runtime: ${rt.provider} (requested ${rt.requested}) — cage ${rt.capabilities.cage}, `
292
+ + `settlement ${rt.capabilities.settlement}, pickup ${rt.capabilities.pickup}\n`);
293
+ for (const [harness, trace] of Object.entries(result.traces)) {
294
+ process.stdout.write(`traces: ${harness.padEnd(8)} ${trace.status}`
295
+ + `${trace.status === 'DRIFT' ? ` — ${trace.detail} (${trace.newest})` : ''}\n`);
296
+ }
297
+ for (const row of result.rows) {
298
+ process.stdout.write(` ${row.status.padEnd(12)} ${row.harness.padEnd(8)} ${row.kind.padEnd(12)} ${row.file}\n`);
299
+ }
300
+ const healthy = s.reachable && s.database_exists && s.ddl_applied === s.ddl_expected
301
+ && s.ddl_source !== 'ABSENT'
302
+ && result.plugin.resolves && result.runtime.provider !== null
303
+ && result.runtime.probe?.ok !== false
304
+ && result.rows.every((r) => r.status === 'ok')
305
+ && Object.values(result.traces).every((t) => t.status !== 'DRIFT');
306
+ summary('doctor', healthy ? 'ok' : 'attention');
307
+ if (!healthy) process.exit(1);
308
+ },
309
+
310
+ async status() {
311
+ const { buildContext } = await import('../src/context.mjs');
312
+ const ctx = buildContext({});
313
+ try {
314
+ const s = await ctx.substrate.status();
315
+ process.stdout.write(`database: ${ctx.substrate.database} — `
316
+ + `${s.reachable ? 'reachable' : 'UNREACHABLE'}, ${s.database_exists ? 'present' : 'absent'}, `
317
+ + `ddl ${s.ddl_applied}/${s.ddl_expected}, ddl source: ${s.ddl_source}, `
318
+ + `yield cause ${s.yield_cause_registered ? 'ok' : 'missing'}\n`);
319
+ summary('status', 'ok');
320
+ } finally {
321
+ await ctx.substrate.close();
322
+ }
323
+ },
324
+
325
+ async uninstall(argv) {
326
+ const { values } = parseArgs({
327
+ args: argv, options: { 'purge-db': { type: 'boolean', default: false } }, allowPositionals: true,
328
+ });
329
+ const { runUninstall } = await import('../src/uninstall.mjs');
330
+ const result = await runUninstall({ purgeDb: values['purge-db'] === true });
331
+ for (const a of result.actions) process.stdout.write(` ${a.action}${a.file ? ` ${a.file}` : ''}\n`);
332
+ process.stdout.write(`database: ${result.database_dropped ? 'DROPPED (--purge-db)' : 'kept'}\n`);
333
+ summary('uninstall', 'ok');
334
+ },
335
+ };
336
+
337
+ /**
338
+ * Everything after the verb is the HARNESS's, verbatim — flags included. oathe consumes only
339
+ * its own `--hermetic` (first occurrence) and one `--` separator; `oathe claude -- --hermetic`
340
+ * hands the harness a literal --hermetic.
341
+ */
342
+ function splitLaunchArgs(argv) {
343
+ const args = [];
344
+ let hermetic = false;
345
+ let passthrough = false;
346
+ for (const a of argv) {
347
+ if (!passthrough && a === '--') { passthrough = true; continue; }
348
+ if (!passthrough && !hermetic && a === '--hermetic') { hermetic = true; continue; }
349
+ args.push(a);
350
+ }
351
+ return { hermetic, args };
352
+ }
353
+
354
+ async function launchHarness(harness, argv) {
355
+ const { hermetic, args } = splitLaunchArgs(argv);
356
+ const { runHarness } = await import('../src/launch.mjs');
357
+ const out = await runHarness({ harness, args, hermetic });
358
+ if (!out.teardown.empty) {
359
+ process.stderr.write(`cage not proven empty: ${out.teardown.detail}\n`);
360
+ summary(harness, 'cage-unclean');
361
+ process.exit(out.exitCode || 1);
362
+ }
363
+ summary(harness, `exit ${out.exitCode}`);
364
+ process.exit(out.exitCode);
365
+ }
366
+
367
+ const [verb, ...rest] = process.argv.slice(2);
368
+ if (!verb || !VERBS.includes(verb)) {
369
+ process.stderr.write(USAGE);
370
+ process.exit(2);
371
+ }
372
+ try {
373
+ await handlers[verb](rest);
374
+ } catch (e) {
375
+ fail(verb, e);
376
+ }
@@ -0,0 +1,45 @@
1
+ # What Oathe reads, stores, and sends
2
+
3
+ Measured against the code at this commit — if behavior and this document disagree, that is a
4
+ bug; open an issue.
5
+
6
+ ## Reads (declared integration surfaces)
7
+
8
+ Oathe does not crawl arbitrary files. It reads exactly these declared surfaces:
9
+
10
+ - **Session transcripts** for sessions in workspaces it manages: the turn-end hook projects
11
+ the current session's own transcript to learn which tasks the session acted on
12
+ (`plugin/hooks/heartbeat.mjs`), and `oathe verify` / `oathe trace` read the transcript
13
+ files linked to a claim. Codex thread indexes are read through `node:sqlite` where the
14
+ Node version provides it.
15
+ - **Harness configuration it manages**: `~/.claude/settings.json` (two owned keys) and
16
+ `~/.codex/config.toml` (via the codex CLI), plus the project's `CLAUDE.md`/`AGENTS.md`
17
+ fenced sections.
18
+ - **Its own state**: the install manifest, backups, and artifact store under `~/.oathe/`,
19
+ and the workspace config (`.oathe.json`).
20
+ - **Git metadata** of the working directory (root, origin) to derive the workspace identity.
21
+
22
+ ## Stores (locally, in YOUR Postgres)
23
+
24
+ Task ids, objectives, claims, statements, verdicts, and transcript file **paths**.
25
+ Transcript contents are not copied into the database.
26
+
27
+ ## Sends
28
+
29
+ Exactly one path sends anything anywhere: **`oathe verify`**. It projects the linked
30
+ transcripts into structured trajectories, slices them to the claim's recorded focus
31
+ intervals where intervals exist (whole-session evidence otherwise), renders a
32
+ character-budgeted evidence view (SAID/CLAIM/DID/GOT lines — not raw transcript bytes),
33
+ and passes that rendering to the verification engine you configured (`claude` or `codex`)
34
+ as a command-line prompt. That content therefore reaches the engine's model provider
35
+ (Anthropic or OpenAI) under YOUR account and their terms. If you never run `verify`,
36
+ nothing leaves your machine. Oathe has no telemetry, no server, and phones home to no one.
37
+
38
+ Two disclosed sharp edges:
39
+
40
+ - **The verifier engine runs OUTSIDE the cage, with your ambient environment**
41
+ (`src/verifier.mjs` spawns the engine CLI with the invoking process's environment). A
42
+ curated environment and bounded execution posture for the verifier is designed, not yet
43
+ shipped — it is a tracked limit in the roadmap, not a silent gap.
44
+ - **The evidence prompt is passed as a process argument**, which is visible to local
45
+ process listings on your machine while the engine runs.
package/package.json CHANGED
@@ -1,34 +1,44 @@
1
1
  {
2
2
  "name": "@oathe/oathe",
3
- "version": "0.0.1",
4
- "description": "Oathe — AI security audits and trust scores for MCP servers, plugins, and AI agent skills. CLI/SDK coming soon; name reserved.",
3
+ "version": "0.2.1",
4
+ "description": "Auto save and verified completion for AI coding agents \u2014 a durable local task board that outlives any one session. D0 preview.",
5
5
  "type": "module",
6
- "main": "./index.js",
6
+ "engines": {
7
+ "node": ">=22"
8
+ },
7
9
  "bin": {
8
- "oathe": "./index.js"
10
+ "oathe": "bin/oathe.mjs"
9
11
  },
10
- "files": [
11
- "index.js",
12
- "LICENSE",
13
- "README.md"
14
- ],
15
- "engines": {
16
- "node": ">=18"
12
+ "scripts": {
13
+ "test": "node --test tests/*.test.mjs",
14
+ "link-runtime": "node scripts/link-runtime.mjs",
15
+ "vendor-ddl": "node scripts/vendor-ddl.mjs",
16
+ "marker-scan": "node scripts/marker-scan.mjs",
17
+ "pack:dry-run": "npm pack --dry-run --ignore-scripts",
18
+ "ci:policy": "node scripts/ci/check-workflows.mjs"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "publishConfig": {
22
+ "access": "public"
17
23
  },
18
- "license": "MIT",
19
- "homepage": "https://oathe.ai",
20
24
  "repository": {
21
25
  "type": "git",
22
26
  "url": "git+https://github.com/oathe-ai/oathe.git"
23
27
  },
24
- "keywords": [
25
- "oathe",
26
- "security",
27
- "audit",
28
- "ai-safety",
29
- "trust-score",
30
- "mcp",
31
- "ai-agent",
32
- "agent-safety"
33
- ]
28
+ "homepage": "https://oathe.ai",
29
+ "files": [
30
+ ".claude-plugin/",
31
+ "assets/",
32
+ "bin/",
33
+ "src/",
34
+ "plugin/",
35
+ "vendor/",
36
+ "docs/PRIVACY.md",
37
+ "LICENSE",
38
+ "NOTICE",
39
+ "README.md"
40
+ ],
41
+ "dependencies": {
42
+ "pg": "^8.23.0"
43
+ }
34
44
  }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "oathe",
3
+ "displayName": "Oathe",
4
+ "version": "0.2.1",
5
+ "description": "Claims are speech acts: your session opens on this folder's board, records progress as statements, and yields what it cannot finish. Horizons move only by deliberate acts \u2014 never by session liveness.",
6
+ "author": {
7
+ "name": "Oathe"
8
+ },
9
+ "license": "Apache-2.0"
10
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "mcpServers": {
3
+ "oathe": {
4
+ "command": "oathe",
5
+ "args": [
6
+ "mcp"
7
+ ],
8
+ "env": {
9
+ "OATHE_WORKSPACE_DIR": "${CLAUDE_PROJECT_DIR}"
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,24 @@
1
+ // PreCompact — compaction is lossy; leave a durable statement on each active claim so the
2
+ // board remembers what the context is about to forget it was doing.
3
+
4
+ import crypto from 'node:crypto';
5
+ import { failSoft } from './lib.mjs';
6
+
7
+ await failSoft(async ({ substrate, workspace, identity }) => {
8
+ const { rows } = await substrate.query(
9
+ `SELECT work_claim_id, task_id FROM cell.work_claim
10
+ WHERE org_id = $1 AND principal_id = $2 AND state = 'active' AND contract_ref LIKE $3`,
11
+ [identity.orgId, identity.principalId, `workspace:${workspace};%`]);
12
+ for (const claim of rows) {
13
+ await substrate.query(
14
+ `INSERT INTO cell.agent_statement (statement_id, org_id, task_id, work_claim_id,
15
+ execution_actor, claim_principal, statement_type, subject_ref, proposition,
16
+ evidence_refs, epistemic_status, asserted_at)
17
+ VALUES ($1, $2, $3, $4, 'oathe-precompact-hook', $5, 'progress', $6,
18
+ 'context compaction imminent — the session''s working set is being compressed; '
19
+ || 'board state and statements are the durable record', '["hook:PreCompact"]'::jsonb,
20
+ 'observed', now())`,
21
+ [crypto.randomUUID(), identity.orgId, claim.task_id, claim.work_claim_id,
22
+ identity.principalId, `task:${claim.task_id}`]);
23
+ }
24
+ });
@@ -0,0 +1,49 @@
1
+ // Stop — the turn-end heartbeat. ONE duty: LINK the session's trace to this workspace's
2
+ // claims (one statement per claim x session, keyed by subject_ref 'trace:<session_id>') so a
3
+ // verifier can later read exactly the transcripts behind the work. It does NOT touch
4
+ // ownership_valid_until: session liveness is not an organizational act (R1, correction
5
+ // packet 2026-08-26); the horizon is set at claim time by the substrate's claim verb.
6
+
7
+ import crypto from 'node:crypto';
8
+ import { failSoft } from './lib.mjs';
9
+ import { projectorFor, claimIntervals } from '../../src/atif.mjs';
10
+
11
+ await failSoft(async ({ substrate, workspace, identity, config, session }) => {
12
+ if (!session?.transcriptPath) return; // no identity handed to this hook — nothing to link
13
+ // R3 (§5): evidence is claim-specific and interval-specific. The session's own structured
14
+ // trace names the tasks it ACTED on (the projector's claim_events); only those claims get
15
+ // this trace linked. No readable trace, or no oathe acts in it → nothing to attribute —
16
+ // a planning-only session leaves no claim evidence.
17
+ let touched;
18
+ try {
19
+ const trajectory = projectorFor(session.transcriptPath).project(session.transcriptPath);
20
+ touched = new Set(claimIntervals(trajectory).map((i) => i.task_id));
21
+ } catch {
22
+ return; // fail-soft: an unreadable or unprojectable trace attributes nothing
23
+ }
24
+ if (touched.size === 0) return;
25
+ // Linkage covers ASSERTED claims too: a claim taken and completed inside a single turn has
26
+ // never seen a heartbeat while active — the turn-end hook is its only chance to leave the
27
+ // trace evidence the verifier will demand. (Settled claims are closed; nothing to link.)
28
+ const { rows } = await substrate.query(
29
+ `SELECT work_claim_id, task_id FROM cell.work_claim
30
+ WHERE org_id = $1 AND principal_id = $2 AND settled_at IS NULL
31
+ AND state IN ('active', 'completion_asserted') AND contract_ref LIKE $3
32
+ AND task_id = ANY($4)`,
33
+ [identity.orgId, identity.principalId, `workspace:${workspace};%`, [...touched]]);
34
+ for (const claim of rows) {
35
+ await substrate.query(
36
+ `INSERT INTO cell.agent_statement (statement_id, org_id, task_id, work_claim_id,
37
+ execution_actor, claim_principal, statement_type, subject_ref, proposition,
38
+ evidence_refs, epistemic_status, asserted_at)
39
+ SELECT $1, $2, $3, $4, $5, $6, 'progress', $7, $8, $9::jsonb, 'observed', now()
40
+ WHERE NOT EXISTS (
41
+ SELECT 1 FROM cell.agent_statement
42
+ WHERE org_id = $2 AND work_claim_id = $4 AND subject_ref = $7)`,
43
+ [crypto.randomUUID(), identity.orgId, claim.task_id, claim.work_claim_id,
44
+ `session:${session.sessionId}`, identity.principalId, `trace:${session.sessionId}`,
45
+ `${session.harness} session ${session.sessionId} worked this claim — transcript at `
46
+ + `${session.transcriptPath} (fan-out derived at read time)`,
47
+ JSON.stringify([session.transcriptPath])]);
48
+ }
49
+ });
@@ -0,0 +1,39 @@
1
+ {
2
+ "description": "Oathe session lifecycle: the board at SessionStart, lease heartbeat at Stop, frame note before compaction. Same three events exist verbatim in Claude Code and Codex. Commands go through the oathe bin on PATH \u2014 the plugin is cached by copy in both harnesses, so the tree carries no paths.",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "matcher": "startup|resume|clear",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "oathe hook render-board",
11
+ "timeout": 8
12
+ }
13
+ ]
14
+ }
15
+ ],
16
+ "Stop": [
17
+ {
18
+ "hooks": [
19
+ {
20
+ "type": "command",
21
+ "command": "oathe hook heartbeat",
22
+ "timeout": 5
23
+ }
24
+ ]
25
+ }
26
+ ],
27
+ "PreCompact": [
28
+ {
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "oathe hook frame-note",
33
+ "timeout": 5
34
+ }
35
+ ]
36
+ }
37
+ ]
38
+ }
39
+ }