@oathe/oathe 0.3.2 → 0.4.3
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/README.md +42 -12
- package/assets/oathe-hero.png +0 -0
- package/bin/node-floor.mjs +16 -0
- package/bin/oathe.mjs +96 -136
- package/docs/PRIVACY.md +7 -6
- package/notch/Oathe Notch.app/Contents/Info.plist +1 -1
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/README.md +33 -18
- package/package.json +9 -5
- package/plugin/.claude-plugin/plugin.json +2 -2
- package/plugin/.cursor-plugin/plugin.json +2 -2
- package/plugin/commands/verify.md +6 -5
- package/plugin/hooks/heartbeat.mjs +14 -5
- package/plugin/hooks/hooks.json +1 -1
- package/plugin/hooks/lib.mjs +7 -5
- package/plugin/hooks/render-board.mjs +3 -3
- package/plugin/skills/oathe-work/SKILL.md +4 -1
- package/src/activation.mjs +3 -0
- package/src/atif.mjs +182 -348
- package/src/board-render.mjs +46 -42
- package/src/breach-digest.mjs +183 -0
- package/src/config.mjs +15 -3
- package/src/context.mjs +1 -1
- package/src/doctor.mjs +30 -8
- package/src/evidence.mjs +153 -0
- package/src/harnesses/catalog.mjs +12 -1
- package/src/harnesses/claude-roster.mjs +49 -0
- package/src/harnesses/claude-transcript.mjs +174 -0
- package/src/harnesses/claude.mjs +35 -2
- package/src/harnesses/codex-rollout.mjs +610 -0
- package/src/harnesses/codex-roster.mjs +88 -0
- package/src/harnesses/codex.mjs +72 -2
- package/src/harnesses/cursor.mjs +10 -8
- package/src/harnesses/fidelity.mjs +123 -0
- package/src/init.mjs +5 -1
- package/src/launch-env.mjs +5 -5
- package/src/launch.mjs +5 -6
- package/src/manifest.mjs +35 -0
- package/src/mcp/connection.mjs +9 -7
- package/src/mcp/oathe-tools.mjs +135 -75
- package/src/node-floor.mjs +44 -0
- package/src/notch-frame.mjs +152 -0
- package/src/oathe-annotator.mjs +113 -0
- package/src/pager.mjs +75 -37
- package/src/runtime/provider.mjs +2 -2
- package/src/session-host.mjs +1 -1
- package/src/sessions.mjs +8 -1
- package/src/speaker.mjs +54 -26
- package/src/statements.mjs +120 -2
- package/src/substrate.mjs +3 -3
- package/src/successor.mjs +2 -3
- package/src/trace-census.mjs +96 -0
- package/src/traces.mjs +98 -6
- package/src/uninstall.mjs +4 -1
- package/src/update.mjs +86 -0
- package/src/verifier.mjs +37 -19
- package/assets/oathe-hero.svg +0 -92
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// The codex rollout roster — pure data, zero imports (both the adapter and the projector
|
|
2
|
+
// consume it; a data-only module keeps the static import graph acyclic). Codex publishes no
|
|
3
|
+
// rollout-format documentation, so this roster IS the pinned contract (docs/traces.md carries
|
|
4
|
+
// it verbatim): every row type the projector handles, or has SEEN and consciously ignores
|
|
5
|
+
// (each with its reason). Rows measured over the 40 most recent real rollouts, 2026-08-31,
|
|
6
|
+
// codex CLI 0.149–0.150; the item stream measured 2026-09-01. A type outside both lists
|
|
7
|
+
// quarantines visibly at projection (extra.record.unrecognized_rows) and fails the census
|
|
8
|
+
// lane as DRIFT — additions tolerate visibly, only missing EXPECTED shapes refuse (founder
|
|
9
|
+
// ruling 2026-08-31).
|
|
10
|
+
|
|
11
|
+
const deepFreeze = (obj) => {
|
|
12
|
+
for (const v of Object.values(obj)) {
|
|
13
|
+
if (v !== null && typeof v === 'object') deepFreeze(v);
|
|
14
|
+
}
|
|
15
|
+
return Object.freeze(obj);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const CODEX_ROLLOUT_ROSTER = deepFreeze({
|
|
19
|
+
line: {
|
|
20
|
+
handled: ['session_meta', 'response_item', 'event_msg', 'turn_context', 'compacted'],
|
|
21
|
+
ignored: {
|
|
22
|
+
world_state: 'environment snapshot — context machinery, not agent actions',
|
|
23
|
+
inter_agent_communication_metadata: 'fan-out routing metadata ({trigger_turn} only) — the sqlite spawn edges and the SubAgentActivity items carry the fact',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
response_item: {
|
|
27
|
+
handled: ['message', 'agent_message', 'reasoning', 'function_call', 'local_shell_call',
|
|
28
|
+
'custom_tool_call', 'function_call_output', 'custom_tool_call_output',
|
|
29
|
+
'tool_search_call', 'tool_search_output', 'compaction'],
|
|
30
|
+
ignored: {},
|
|
31
|
+
},
|
|
32
|
+
event_msg: {
|
|
33
|
+
handled: ['token_count', 'item_completed'],
|
|
34
|
+
ignored: {
|
|
35
|
+
task_started: 'turn lifecycle marker — response_item is ground truth (docs/traces.md)',
|
|
36
|
+
task_complete: 'turn lifecycle marker — response_item is ground truth',
|
|
37
|
+
thread_settings_applied: 'settings bookkeeping, not agent action',
|
|
38
|
+
user_message: 'nudge-channel duplicate of the response_item user message',
|
|
39
|
+
agent_message: 'nudge-channel duplicate of the response_item agent message',
|
|
40
|
+
agent_reasoning: 'nudge-channel duplicate of the response_item reasoning row',
|
|
41
|
+
turn_aborted: 'turn lifecycle marker — the absence of further items already shows it',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
// The typed item stream (item_completed.item.type): the vendor's own decode of what the exec
|
|
45
|
+
// source wraps (CommandExecution, McpToolCall, FileChange), lifecycle facts that exist
|
|
46
|
+
// nowhere else (SubAgentActivity — its id IS the spawn call's), and one action with no
|
|
47
|
+
// response_item counterpart at all (Extension: web.search). Measured 2026-09-01: 100% of
|
|
48
|
+
// cli/exec/child rollouts carry it, 8/14 vscode — enrichment of the calls, never the spine.
|
|
49
|
+
item: {
|
|
50
|
+
handled: ['CommandExecution', 'McpToolCall', 'FileChange', 'SubAgentActivity', 'Extension'],
|
|
51
|
+
ignored: {
|
|
52
|
+
Reasoning: 'the response_item reasoning row is the fact (encrypted either way)',
|
|
53
|
+
AgentMessage: 'the response_item message row is the fact',
|
|
54
|
+
UserMessage: 'the response_item user message row is the fact',
|
|
55
|
+
CollabAgentToolCall: 'the collaboration function_call and its output are the fact; the item repeats them',
|
|
56
|
+
ContextCompaction: 'the compacted line row is the fact',
|
|
57
|
+
DynamicToolCall: 'a dynamic tool call rides its own function_call/output pair',
|
|
58
|
+
Plan: 'a plan update is the agent\'s own words, carried by the message row',
|
|
59
|
+
ImageView: 'an image view is a read, not an action the record claims',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/** The response_item types that ARE tool calls — the fidelity extractors' view of actions. */
|
|
65
|
+
export const CODEX_CALL_TYPES = Object.freeze(
|
|
66
|
+
new Set(['function_call', 'local_shell_call', 'custom_tool_call', 'tool_search_call']));
|
|
67
|
+
|
|
68
|
+
/** The item types that complete a call — the second source of the same action, cross-checked. */
|
|
69
|
+
export const CORRELATABLE_ITEMS = Object.freeze(new Set(['CommandExecution', 'McpToolCall', 'FileChange']));
|
|
70
|
+
|
|
71
|
+
// The inter-agent bus (measured 2026-09-01): an ADDRESSED agent_message carries `author` and
|
|
72
|
+
// `recipient` as agent paths — the root thread is `/root`, a child `/root/<nickname>` — and a
|
|
73
|
+
// typed first line (`Message Type: FINAL_ANSWER | NEW_TASK | MESSAGE`), then headers and the
|
|
74
|
+
// payload. An unaddressed agent_message (35 of 45 across the 40 newest rollouts) is the
|
|
75
|
+
// agent's own words.
|
|
76
|
+
export const CODEX_ROOT_AGENT_PATH = '/root';
|
|
77
|
+
export const INTER_AGENT_MESSAGE_TYPE = /^Message Type:\s*(\S+)/;
|
|
78
|
+
|
|
79
|
+
/** One parsed rollout row → its roster coordinate (the census classifier). */
|
|
80
|
+
export function codexKindOf(row) {
|
|
81
|
+
if (row?.type === 'event_msg' && row.payload?.type === 'item_completed') {
|
|
82
|
+
return { channel: 'item', type: row.payload.item?.type };
|
|
83
|
+
}
|
|
84
|
+
if (row?.type === 'response_item' || row?.type === 'event_msg') {
|
|
85
|
+
return { channel: row.type, type: row.payload?.type };
|
|
86
|
+
}
|
|
87
|
+
return { channel: 'line', type: row?.type };
|
|
88
|
+
}
|
package/src/harnesses/codex.mjs
CHANGED
|
@@ -10,6 +10,14 @@ import path from 'node:path';
|
|
|
10
10
|
|
|
11
11
|
import { Harness, HarnessOnboardError } from './harness.mjs';
|
|
12
12
|
import { cwdDialect } from './dialects.mjs';
|
|
13
|
+
import { CODEX_ROLLOUT_ROSTER, CODEX_CALL_TYPES, CORRELATABLE_ITEMS, CODEX_ROOT_AGENT_PATH, codexKindOf } from './codex-roster.mjs';
|
|
14
|
+
import { makeFidelity } from './fidelity.mjs';
|
|
15
|
+
import { CodexTraceStore } from '../traces.mjs';
|
|
16
|
+
|
|
17
|
+
/** The raw call payloads of a rollout — the fidelity extractors' one reading of actions. */
|
|
18
|
+
const codexRawCalls = (entries) => entries
|
|
19
|
+
.filter((r) => r.type === 'response_item' && CODEX_CALL_TYPES.has(r.payload?.type))
|
|
20
|
+
.map((r) => r.payload);
|
|
13
21
|
import { sha256Hex } from '../manifest.mjs';
|
|
14
22
|
|
|
15
23
|
// The id Codex knows the plugin by (plugin@marketplace) — the registrations install it and
|
|
@@ -63,10 +71,72 @@ export class CodexHarness extends Harness {
|
|
|
63
71
|
extract: (stdout) => stdout,
|
|
64
72
|
});
|
|
65
73
|
static traces = Object.freeze({
|
|
66
|
-
store:
|
|
74
|
+
store: ({ home } = {}) => new CodexTraceStore({ home, harness: this.harnessName }),
|
|
67
75
|
newest: (store) => store.newestRollout(),
|
|
68
|
-
projector: async ({ store }) => new (await import('
|
|
76
|
+
projector: async ({ store }) => new (await import('./codex-rollout.mjs')).CodexAtifProjector({ store }),
|
|
69
77
|
ownsPath: (file) => String(file).includes(`${path.sep}.codex${path.sep}`),
|
|
78
|
+
roster: CODEX_ROLLOUT_ROSTER,
|
|
79
|
+
kindOf: codexKindOf,
|
|
80
|
+
recent: (store, { days, maxFiles }) => store.recentRollouts({ days, maxFiles }),
|
|
81
|
+
// Harbor's converter for this harness (AgentName 'codex') reads a trial's rollouts from
|
|
82
|
+
// <logs_dir>/sessions — the mirror of ~/.codex/sessions (harbor 0.22.0, measured 2026-09-01).
|
|
83
|
+
harbor: Object.freeze({ agent: 'codex', sessions: Object.freeze({ home: '.codex/sessions', logs: 'sessions' }) }),
|
|
84
|
+
fidelity: makeFidelity({
|
|
85
|
+
// hasSource judges what the raw record actually ARGUES: a legitimately empty argument
|
|
86
|
+
// set (list_agents "{}" — and a single inner tools.x({}) call in exec source) projects
|
|
87
|
+
// empty faithfully; only a record that carries content demands the projection carry it.
|
|
88
|
+
rawCalls: async (entries) => {
|
|
89
|
+
const { ExecCallReader } = await import('./codex-rollout.mjs');
|
|
90
|
+
const reader = new ExecCallReader();
|
|
91
|
+
const hasContent = (v) => {
|
|
92
|
+
if (v == null) return false;
|
|
93
|
+
if (typeof v === 'string') return !['', '{}', '[]', 'null'].includes(v.trim());
|
|
94
|
+
return typeof v === 'object' ? Object.keys(v).length > 0 : Boolean(v);
|
|
95
|
+
};
|
|
96
|
+
return codexRawCalls(entries).map((p) => {
|
|
97
|
+
if (p.type === 'custom_tool_call' && typeof p.input === 'string' && p.input.trim() !== '') {
|
|
98
|
+
const inner = reader.read(p.input);
|
|
99
|
+
const single = inner.length === 1 && inner[0].args !== null ? inner[0] : null;
|
|
100
|
+
const argful = single
|
|
101
|
+
? (typeof single.args === 'object' ? Object.keys(single.args).length > 0 : true)
|
|
102
|
+
: true; // multi-call or unparseable source projects as {input: raw} — never empty
|
|
103
|
+
return { id: p.call_id, hasSource: argful };
|
|
104
|
+
}
|
|
105
|
+
return { id: p.call_id, hasSource: hasContent(p.arguments) || hasContent(p.action) };
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
// Usage the record actually CARRIES: a token_count with info: null (a documented vendor
|
|
109
|
+
// state) owes the projection nothing.
|
|
110
|
+
hasRawTokens: (entries) => entries.some((r) => r.type === 'event_msg' && r.payload?.type === 'token_count' && r.payload.info?.last_token_usage),
|
|
111
|
+
// Applicability is a REAL act, not chatter: only an inner tools.<oathe verb>(...) call
|
|
112
|
+
// (or a composed function_call name) counts — a grep ABOUT oathe_claim is not a claim.
|
|
113
|
+
hasOatheActs: async (entries) => {
|
|
114
|
+
const [{ ExecCallReader }, { oatheVerbFor }] = await Promise.all([
|
|
115
|
+
import('./codex-rollout.mjs'), import('../oathe-annotator.mjs')]);
|
|
116
|
+
const reader = new ExecCallReader();
|
|
117
|
+
return codexRawCalls(entries).some((p) => {
|
|
118
|
+
if (p.type === 'custom_tool_call' && typeof p.input === 'string') {
|
|
119
|
+
return reader.read(p.input).some((call) => oatheVerbFor(call.tool) !== null);
|
|
120
|
+
}
|
|
121
|
+
if (!p.name) return false;
|
|
122
|
+
const composed = p.namespace ? `${p.namespace}__${String(p.name).replace(/^_/, '')}` : p.name;
|
|
123
|
+
return oatheVerbFor(composed) !== null;
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
childIds: (entries, trajectory, { store }) => store.childThreads(trajectory.session_id).map((c) => c.thread_id),
|
|
127
|
+
// The items that complete a call — the second source the cross-source probe checks.
|
|
128
|
+
rawItems: (entries) => entries
|
|
129
|
+
.filter((r) => r.type === 'event_msg' && r.payload?.type === 'item_completed' && CORRELATABLE_ITEMS.has(r.payload.item?.type))
|
|
130
|
+
.map((r) => ({ type: r.payload.item.type, id: r.payload.item.id })),
|
|
131
|
+
// Messages addressed TO this thread on the inter-agent bus (self = the spawn's agent
|
|
132
|
+
// path, else the root) — never this agent's own words.
|
|
133
|
+
inboundTexts: (entries) => {
|
|
134
|
+
const self = entries[0]?.payload?.source?.subagent?.thread_spawn?.agent_path ?? CODEX_ROOT_AGENT_PATH;
|
|
135
|
+
return entries
|
|
136
|
+
.filter((r) => r.type === 'response_item' && r.payload?.type === 'agent_message' && r.payload.recipient === self)
|
|
137
|
+
.map((r) => (r.payload.content ?? []).map((p) => p?.text ?? '').join('\n'));
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
70
140
|
});
|
|
71
141
|
static docs = Object.freeze([
|
|
72
142
|
'codex/mcp', 'codex/config-reference', 'codex/environment-variables', 'codex/agents-md', 'codex/hooks',
|
package/src/harnesses/cursor.mjs
CHANGED
|
@@ -29,9 +29,8 @@ export class CursorHarness extends Harness {
|
|
|
29
29
|
static harnessName = 'cursor';
|
|
30
30
|
static displayName = 'Cursor';
|
|
31
31
|
static covers = 'CLI/Desktop App';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
static cliBins = Object.freeze(['cursor-agent', 'cursor']);
|
|
32
|
+
// The CLI is `agent` — cursor/cli-installation.md verifies an install with `agent --version`.
|
|
33
|
+
static bin = 'agent';
|
|
35
34
|
static clientNames = Object.freeze(['cursor']);
|
|
36
35
|
static contextFiles = Object.freeze(['AGENTS.md']);
|
|
37
36
|
static projectDirEnvVar = 'CURSOR_PROJECT_DIR';
|
|
@@ -40,21 +39,24 @@ export class CursorHarness extends Harness {
|
|
|
40
39
|
static hooks = Object.freeze({ dialect: workspaceRootsDialect });
|
|
41
40
|
// The missing primitive, restored (founder ruling 2026-08-30: all harnesses on the same
|
|
42
41
|
// primitives, each with its own adapter): cursor launches its interactive CLI agent.
|
|
43
|
-
static launch = Object.freeze({ splash: true, bin: '
|
|
44
|
-
// The IDE's spawned children live inside Cursor.app (helper bundles)
|
|
42
|
+
static launch = Object.freeze({ splash: true, bin: 'agent' });
|
|
43
|
+
// The IDE's spawned children live inside Cursor.app (helper bundles). The CLI's process is
|
|
44
|
+
// named by whichever path launched it: `agent`, or `cursor-agent` — the versioned executable
|
|
45
|
+
// the `agent` symlink points to, and the installer's legacy symlink (measured 2026-09-02).
|
|
46
|
+
static cliExecutables = Object.freeze(['agent', 'cursor-agent']);
|
|
45
47
|
static surfaces = Object.freeze({
|
|
46
48
|
ownsExec: (exec) => exec.includes(`${path.sep}Cursor.app${path.sep}`)
|
|
47
|
-
|| CursorHarness.
|
|
49
|
+
|| CursorHarness.cliExecutables.includes(path.basename(exec)),
|
|
48
50
|
name: () => 'cursor',
|
|
49
51
|
});
|
|
50
52
|
// cursor/cli-installation.md:10 (pinned 2026-08-29).
|
|
51
|
-
static install = Object.freeze({ installer: 'curl https://cursor.com/install -fsS | bash', bin: '
|
|
53
|
+
static install = Object.freeze({ installer: 'curl https://cursor.com/install -fsS | bash', bin: 'agent', versionArgs: ['--version'] });
|
|
52
54
|
// Headless: `agent -p --output-format json` → {type:"result", result} (cursor/cli-output-format.md);
|
|
53
55
|
// CI auth CURSOR_API_KEY (cursor/cli-authentication.md:24-37, cli-github-actions.md:17). A fresh
|
|
54
56
|
// project dir is untrusted — the CLI refuses to run there without --trust (observed live 2026-08-29).
|
|
55
57
|
static headless = Object.freeze({
|
|
56
58
|
auth: ['CURSOR_API_KEY'],
|
|
57
|
-
command: (prompt, model = null) => ['
|
|
59
|
+
command: (prompt, model = null) => ['agent', ['-p', prompt, '--trust', '--output-format', 'json', ...(model ? ['--model', model] : [])]],
|
|
58
60
|
extract: (stdout) => CursorHarness.extractJsonResult(stdout),
|
|
59
61
|
});
|
|
60
62
|
static traces = null; // Cursor keeps no session store we read; its hook payload carries transcript_path: null
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// The fidelity probes — ONE probe logic for every engine (DRY), parameterized by the
|
|
2
|
+
// adapter's raw-record extractors. A probe answers: does the projection CARRY what the raw
|
|
3
|
+
// record carries? `applicable` is the honesty valve — a record with no tool calls owes no
|
|
4
|
+
// tool-call fidelity; a probe applicable to nothing is n/a, never a stolen pass or a failure.
|
|
5
|
+
|
|
6
|
+
const PASS = Object.freeze({ applicable: true, ok: true, detail: null });
|
|
7
|
+
const NA = Object.freeze({ applicable: false, ok: true, detail: null });
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {{
|
|
11
|
+
* rawCalls: (entries) => Array<{id: string, hasSource: boolean}>|Promise<Array<{id, hasSource}>>,
|
|
12
|
+
* hasRawTokens: (entries) => boolean,
|
|
13
|
+
* hasOatheActs: (entries) => Promise<boolean>,
|
|
14
|
+
* childIds: (entries, trajectory, {store, file}) => Array<string>|Promise<Array<string>>,
|
|
15
|
+
* rawItems: (entries) => Array<{type: string, id: string}>,
|
|
16
|
+
* inboundTexts: (entries) => Array<string>,
|
|
17
|
+
* }} extractors — the adapter's readers of its own raw format; the trajectory a probe sees is
|
|
18
|
+
* the ANNOTATED one (claim events are the annotator's), the file the record it came from.
|
|
19
|
+
* rawItems: the record's correlatable items (a second source for the same actions) — an
|
|
20
|
+
* engine with no item stream returns none and the cross-source probe is n/a for it.
|
|
21
|
+
* inboundTexts: the bodies of messages OTHER agents or the harness sent this thread —
|
|
22
|
+
* what must never surface as this agent's own SAID.
|
|
23
|
+
*/
|
|
24
|
+
export function makeFidelity({ rawCalls, hasRawTokens, hasOatheActs, childIds, rawItems, inboundTexts }) {
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
'tool-call-args': async (entries, trajectory) => {
|
|
27
|
+
const raw = await rawCalls(entries);
|
|
28
|
+
if (raw.length === 0) return NA;
|
|
29
|
+
const projected = new Map();
|
|
30
|
+
for (const step of trajectory.steps ?? []) {
|
|
31
|
+
for (const call of step.tool_calls ?? []) projected.set(call.tool_call_id, call);
|
|
32
|
+
}
|
|
33
|
+
for (const { id, hasSource } of raw) {
|
|
34
|
+
const call = projected.get(id);
|
|
35
|
+
if (!call) {
|
|
36
|
+
return { applicable: true, ok: false, detail: `raw call '${id}' is missing from the projection [OATHE_TRACE_FIDELITY_EMPTY_ARGS]` };
|
|
37
|
+
}
|
|
38
|
+
if (hasSource && Object.keys(call.arguments ?? {}).length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
applicable: true,
|
|
41
|
+
ok: false,
|
|
42
|
+
detail: `raw call '${id}' carries its command source; the projection carries arguments {} [OATHE_TRACE_FIDELITY_EMPTY_ARGS]`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return PASS;
|
|
47
|
+
},
|
|
48
|
+
'token-metrics': async (entries, trajectory) => {
|
|
49
|
+
if (!hasRawTokens(entries)) return NA;
|
|
50
|
+
// The ROOT's own steps — final_metrics folds the children's usage in, which could mask
|
|
51
|
+
// a root whose usage the projection lost.
|
|
52
|
+
const own = (trajectory.steps ?? []).reduce((n, s) => n + (s.metrics?.prompt_tokens ?? 0) + (s.metrics?.completion_tokens ?? 0), 0);
|
|
53
|
+
if (own > 0) return PASS;
|
|
54
|
+
return { applicable: true, ok: false, detail: 'raw token accounting present; the projection\'s own steps carry none [OATHE_TRACE_FIDELITY_ZERO_METRICS]' };
|
|
55
|
+
},
|
|
56
|
+
'claim-events': async (entries, trajectory) => {
|
|
57
|
+
if (!(await hasOatheActs(entries))) return NA;
|
|
58
|
+
const survived = (trajectory.steps ?? []).some((s) => (s.extra?.oathe?.claim_events ?? []).length > 0);
|
|
59
|
+
if (survived) return PASS;
|
|
60
|
+
return { applicable: true, ok: false, detail: 'the raw record calls an oathe verb; the projection carries no claim_events [OATHE_TRACE_FIDELITY_CLAIMS_LOST]' };
|
|
61
|
+
},
|
|
62
|
+
'subagent-embedding': async (entries, trajectory, { store, file }) => {
|
|
63
|
+
const ids = await childIds(entries, trajectory, { store, file });
|
|
64
|
+
if (ids.length === 0) return NA;
|
|
65
|
+
const embedded = new Set((trajectory.subagent_trajectories ?? []).map((c) => c.trajectory_id));
|
|
66
|
+
const missing = ids.filter((id) => !embedded.has(id));
|
|
67
|
+
if (missing.length === 0) return PASS;
|
|
68
|
+
return { applicable: true, ok: false, detail: `children not embedded: ${missing.join(', ')} [OATHE_TRACE_FIDELITY_SUBAGENTS_LOST]` };
|
|
69
|
+
},
|
|
70
|
+
// Two sources for one action (the response_item rows and the item stream) must agree in
|
|
71
|
+
// the projection: an item that completed no call is a join that failed, and a result whose
|
|
72
|
+
// text states one exit code while the record states another landed on the wrong call.
|
|
73
|
+
'cross-source': async (entries, trajectory) => {
|
|
74
|
+
if (rawItems(entries).length === 0) return NA;
|
|
75
|
+
const orphans = trajectory.extra?.record?.uncorrelated_items;
|
|
76
|
+
if (orphans) {
|
|
77
|
+
const names = Object.entries(orphans).map(([type, n]) => `${type}×${n}`).join(', ');
|
|
78
|
+
return { applicable: true, ok: false, detail: `uncorrelated items completed no call: ${names} [OATHE_TRACE_FIDELITY_CROSS_SOURCE]` };
|
|
79
|
+
}
|
|
80
|
+
const { statedExitCode } = await import('../oathe-annotator.mjs');
|
|
81
|
+
for (const step of trajectory.steps ?? []) {
|
|
82
|
+
for (const result of step.observation?.results ?? []) {
|
|
83
|
+
const structural = result.extra?.record?.exit_code;
|
|
84
|
+
const stated = statedExitCode(result.content);
|
|
85
|
+
if (Number.isInteger(structural) && stated !== null && stated !== structural) {
|
|
86
|
+
return {
|
|
87
|
+
applicable: true,
|
|
88
|
+
ok: false,
|
|
89
|
+
detail: `result of '${result.source_call_id}' states exit code ${stated} in its text while the record says ${structural} [OATHE_TRACE_FIDELITY_CROSS_SOURCE]`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return PASS;
|
|
95
|
+
},
|
|
96
|
+
// The 2026-08-31 misattribution, held closed: a message another agent sent this thread
|
|
97
|
+
// (a child's answer, a task-notification) that surfaces as an AGENT step's own message is
|
|
98
|
+
// the agent claiming words it never said. Bodies are compared on their first 200
|
|
99
|
+
// whitespace-normalized characters — the way a body would be quoted, not the way it was stored.
|
|
100
|
+
attribution: async (entries, trajectory) => {
|
|
101
|
+
const bodies = inboundTexts(entries).map((text) => collapse(text).slice(0, 200)).filter((b) => b.length > 0);
|
|
102
|
+
if (bodies.length === 0) return NA;
|
|
103
|
+
for (const step of trajectory.steps ?? []) {
|
|
104
|
+
if (step.source !== 'agent') continue;
|
|
105
|
+
const said = collapse(step.message ?? ''); // whole — only the body is bounded
|
|
106
|
+
const quoted = bodies.find((body) => said.includes(body));
|
|
107
|
+
if (quoted !== undefined) {
|
|
108
|
+
return {
|
|
109
|
+
applicable: true,
|
|
110
|
+
ok: false,
|
|
111
|
+
detail: `step ${step.step_id} renders an inbound message as the agent's own words ("${quoted.slice(0, 60)}…") [OATHE_TRACE_FIDELITY_MISATTRIBUTED]`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return PASS;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The comparable shape of a text: whitespace collapsed — the way a body is quoted, not stored. */
|
|
121
|
+
function collapse(text) {
|
|
122
|
+
return String(text).replaceAll(/\s+/g, ' ').trim();
|
|
123
|
+
}
|
package/src/init.mjs
CHANGED
|
@@ -144,7 +144,11 @@ export async function runInit({
|
|
|
144
144
|
for (const action of wireNotch({ home: ctx.home, manifest, config: ctx.config, version, packageRoot: ctx.paths.packageRoot, ...(exec ? { exec } : {}) })) {
|
|
145
145
|
actions.push({ harness: 'notch', ...action });
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
// This run took as long as its CLI calls did; a hook or a server may have saved a row in
|
|
148
|
+
// the meantime. Under the lock, merge what landed on disk, then record this run — never a
|
|
149
|
+
// snapshot over a living file (B4, 2026-09-03).
|
|
150
|
+
const { withFileLock } = await import('./fslock.mjs');
|
|
151
|
+
await withFileLock(manifest.manifestPath, async () => { manifest.refresh({ merge: true }); manifest.save(); });
|
|
148
152
|
|
|
149
153
|
return {
|
|
150
154
|
plan,
|
package/src/launch-env.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// oathe — the launched-session
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// the launcher writes the block
|
|
1
|
+
// oathe — the launched-session env block. The launcher hands the caged child the oathe wiring
|
|
2
|
+
// plus OATHE_LAUNCHED_HARNESS, the custody marker naming which harness `oathe <harness>`
|
|
3
|
+
// launched — a marker and nothing more: hooks fire in every session, and tool access is gated
|
|
4
|
+
// by workspace resolution (src/workspace-resolver.mjs), never by who spawned the session.
|
|
5
|
+
// Named once here: the launcher writes the block.
|
|
6
6
|
|
|
7
7
|
export const LAUNCHED_HARNESS_ENV = 'OATHE_LAUNCHED_HARNESS';
|
|
8
8
|
|
package/src/launch.mjs
CHANGED
|
@@ -81,9 +81,8 @@ function curatedEnv(env, { hermetic, extra }) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* ONE launcher,
|
|
85
|
-
*
|
|
86
|
-
* Stop/PreCompact; the docs pass proved both exist, so the premise — and the wait — died.)
|
|
84
|
+
* ONE launcher, every launchable harness (Claude Code, Codex) — same cage, same session host,
|
|
85
|
+
* same pre-flight; only the binary differs.
|
|
87
86
|
*
|
|
88
87
|
* @param {{harness: 'claude'|'codex', env?: object, cwd?: string, args?: string[],
|
|
89
88
|
* hermetic?: boolean, exec?: object, observeIntervalMs?: number}} o
|
|
@@ -109,9 +108,9 @@ export async function runHarness({
|
|
|
109
108
|
import('./board-render.mjs'), import('./pager.mjs'), import('./registry.mjs'),
|
|
110
109
|
]);
|
|
111
110
|
const registry = new WorkspaceRegistry({ registryPath: paths.registryPath });
|
|
112
|
-
const
|
|
113
|
-
const seen = await renderBoard({ client: substrate, identity, workspace, config, synthetic,
|
|
114
|
-
out.write(renderSplash({
|
|
111
|
+
const digest = await new Pager({ client: substrate, identity, config, registry }).digest();
|
|
112
|
+
const seen = await renderBoard({ client: substrate, identity, workspace, config, synthetic, digest });
|
|
113
|
+
out.write(renderSplash({ digest, sections: seen.sections, workspace: seen.lens }));
|
|
115
114
|
openWork = Object.values(seen.sections).some((rows) => rows.length > 0);
|
|
116
115
|
} catch (e) {
|
|
117
116
|
out.write(`Oathe board unavailable (${String(e?.message || e).slice(0, 120)})\n`);
|
package/src/manifest.mjs
CHANGED
|
@@ -44,6 +44,10 @@ export class InstallManifest {
|
|
|
44
44
|
{ format: MANIFEST_FORMAT, saved_at: this.clock(), rows: this.rows, backups: this.backups });
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** Row identities this object removed since it last read the file — a merge-refresh must not
|
|
48
|
+
* bring them back from a disk copy that predates the removal. */
|
|
49
|
+
#removed = new Set();
|
|
50
|
+
|
|
47
51
|
/** One row per (harness, file, kind, detail identity); a re-run replaces its own row. */
|
|
48
52
|
upsert({ harness, file, kind, scope = 'user', detail = null, blockVersion, sha256 }) {
|
|
49
53
|
const key = this.#key({ harness, file, kind, detail });
|
|
@@ -54,6 +58,7 @@ export class InstallManifest {
|
|
|
54
58
|
const at = this.rows.findIndex((r) => this.#key(r) === key);
|
|
55
59
|
if (at === -1) this.rows.push(row);
|
|
56
60
|
else this.rows[at] = row;
|
|
61
|
+
this.#removed.delete(key); // written again in the same run: a row, not a removal
|
|
57
62
|
return row;
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -65,9 +70,39 @@ export class InstallManifest {
|
|
|
65
70
|
removeWhere(predicate) {
|
|
66
71
|
const dropped = this.rows.filter(predicate);
|
|
67
72
|
this.rows = this.rows.filter((r) => !predicate(r));
|
|
73
|
+
for (const row of dropped) this.#removed.add(this.#key(row));
|
|
68
74
|
return dropped;
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Re-read this manifest's file into THIS object (B4, 2026-09-03). A holder that loaded long
|
|
79
|
+
* ago — the MCP server's context, built once per config change and kept for days — used to
|
|
80
|
+
* write its snapshot back over everything `oathe init` and `oathe uninstall` had recorded
|
|
81
|
+
* since. Plain: rows and backups become the file's (the caller holds the lock and mutates
|
|
82
|
+
* next). With `merge`: rows another writer landed since this object loaded are kept, rows
|
|
83
|
+
* this object removed stay removed, and this object's own rows win on identity — what init
|
|
84
|
+
* and uninstall need at the end of a run long enough for a hook to activate in between.
|
|
85
|
+
* A missing file reads as empty, as load() reads it.
|
|
86
|
+
* @returns {InstallManifest} this
|
|
87
|
+
*/
|
|
88
|
+
refresh({ merge = false } = {}) {
|
|
89
|
+
const fresh = InstallManifest.load({ manifestPath: this.manifestPath, backupsDir: this.backupsDir, clock: this.clock });
|
|
90
|
+
if (!merge) {
|
|
91
|
+
this.rows = fresh.rows;
|
|
92
|
+
this.backups = fresh.backups;
|
|
93
|
+
} else {
|
|
94
|
+
const mine = new Set(this.rows.map((r) => this.#key(r)));
|
|
95
|
+
for (const row of fresh.rows) {
|
|
96
|
+
const key = this.#key(row);
|
|
97
|
+
if (!mine.has(key) && !this.#removed.has(key)) this.rows.push(row);
|
|
98
|
+
}
|
|
99
|
+
const backedUp = new Set(this.backups.map((b) => b.file));
|
|
100
|
+
for (const b of fresh.backups) if (!backedUp.has(b.file)) this.backups.push(b);
|
|
101
|
+
}
|
|
102
|
+
this.#removed.clear();
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
71
106
|
/**
|
|
72
107
|
* Copy `file` into backups/ before oathe's FIRST write to it — later calls are no-ops, so the
|
|
73
108
|
* backup is always the pre-oathe state. A file that does not exist yet is recorded as
|
package/src/mcp/connection.mjs
CHANGED
|
@@ -13,7 +13,8 @@ import { OatheConfig } from '../config.mjs';
|
|
|
13
13
|
import { WorkspaceResolver } from '../workspace-resolver.mjs';
|
|
14
14
|
import { harnessForClient } from '../harnesses/catalog.mjs';
|
|
15
15
|
import { resolveSpeaker } from '../speaker.mjs';
|
|
16
|
-
import { homeOf } from '../paths.mjs';
|
|
16
|
+
import { buildPaths, homeOf } from '../paths.mjs';
|
|
17
|
+
import { packageVersion } from '../context.mjs';
|
|
17
18
|
|
|
18
19
|
export class McpConnection {
|
|
19
20
|
/**
|
|
@@ -32,6 +33,7 @@ export class McpConnection {
|
|
|
32
33
|
this.factory = toolContextFactory ?? defaultToolContextFactory({ env });
|
|
33
34
|
this.cwd = cwd;
|
|
34
35
|
this.home = home;
|
|
36
|
+
this.version = packageVersion(buildPaths(env)); // the package's own file — no environment to poison
|
|
35
37
|
this.client = { capabilities: {}, info: null };
|
|
36
38
|
this.pending = new Map();
|
|
37
39
|
this.requestSeq = 0;
|
|
@@ -80,7 +82,7 @@ export class McpConnection {
|
|
|
80
82
|
await this.#invalidate();
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
|
-
const out = await dispatch(msg, { tools: this.served });
|
|
85
|
+
const out = await dispatch(msg, { tools: this.served, version: this.version });
|
|
84
86
|
if (out) this.#write(out);
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -155,7 +157,6 @@ export class McpConnection {
|
|
|
155
157
|
* activation seam (src/activation.mjs) — the resolution's `synthetic` fact rides into both
|
|
156
158
|
* the tools (board scope) and the seam (no registration, no fences). */
|
|
157
159
|
export function defaultToolContextFactory({ env }) {
|
|
158
|
-
let speaker = null; // observed once per server process — our own ancestry never changes
|
|
159
160
|
return async ({ resolution, client }) => {
|
|
160
161
|
const [
|
|
161
162
|
{ Substrate }, { buildPaths }, { OatheConfig }, { WorkspaceRegistry }, { InstallManifest },
|
|
@@ -169,7 +170,7 @@ export function defaultToolContextFactory({ env }) {
|
|
|
169
170
|
const substrate = new Substrate({ database: config.get('db'), paths, env, config });
|
|
170
171
|
const identity = {
|
|
171
172
|
orgId: config.get('org'),
|
|
172
|
-
principalId: config.get('principal')
|
|
173
|
+
principalId: config.get('principal'),
|
|
173
174
|
department: config.get('department'),
|
|
174
175
|
};
|
|
175
176
|
const activation = new ActivationSeam({
|
|
@@ -191,9 +192,10 @@ export function defaultToolContextFactory({ env }) {
|
|
|
191
192
|
workspace: resolution.ref,
|
|
192
193
|
synthetic: resolution.synthetic,
|
|
193
194
|
activation,
|
|
194
|
-
// The SPEAKER primitive — resolved
|
|
195
|
-
//
|
|
196
|
-
|
|
195
|
+
// The SPEAKER primitive — resolved FRESH per context build: our own ancestry never
|
|
196
|
+
// changes, but the device session registry does (a /clear, a rotation), and a stale
|
|
197
|
+
// memo would stamp the first session's id on every later act (found 2026-09-01).
|
|
198
|
+
speaker: resolveSpeaker({ clientName: client?.info?.name, sessionsPath: paths.sessionsPath }),
|
|
197
199
|
|
|
198
200
|
// Verification over MCP DISPATCHES — the engine never runs inside the server (a run is
|
|
199
201
|
// minutes; the server must keep answering). ONE seam, every surface (verifierSeam).
|