@oathe/oathe 0.2.3 → 0.3.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.
- package/NOTICE +3 -4
- package/README.md +15 -45
- package/assets/oathe-hero.svg +92 -0
- package/bin/oathe.mjs +397 -59
- package/docs/PRIVACY.md +13 -5
- package/notch/Oathe Notch.app/Contents/Info.plist +13 -0
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/Oathe Notch.app/Contents/_CodeSignature/CodeResources +115 -0
- package/notch/README.md +88 -0
- package/package.json +13 -4
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +36 -0
- package/plugin/.mcp.json +1 -4
- package/plugin/commands/verify.md +18 -0
- package/plugin/hooks/frame-note.mjs +5 -3
- package/plugin/hooks/heartbeat.mjs +21 -25
- package/plugin/hooks/lib.mjs +96 -33
- package/plugin/hooks/render-board.mjs +47 -7
- package/src/activation.mjs +126 -0
- package/src/atif.mjs +4 -13
- package/src/blocks.mjs +113 -8
- package/src/board-render.mjs +55 -29
- package/src/config.mjs +100 -15
- package/src/context.mjs +4 -8
- package/src/doctor.mjs +96 -15
- package/src/fence.mjs +85 -0
- package/src/fslock.mjs +51 -0
- package/src/harnesses/catalog.mjs +180 -0
- package/src/harnesses/claude.mjs +196 -0
- package/src/harnesses/codex.mjs +188 -0
- package/src/harnesses/cursor.mjs +234 -0
- package/src/harnesses/dialects.mjs +52 -0
- package/src/harnesses/harness.mjs +203 -0
- package/src/harnesses/surfaces.mjs +71 -0
- package/src/home.mjs +107 -0
- package/src/init.mjs +101 -21
- package/src/launch-env.mjs +1 -51
- package/src/launch.mjs +36 -105
- package/src/manifest.mjs +7 -3
- package/src/mcp/connection.mjs +218 -0
- package/src/mcp/oathe-tools.mjs +380 -141
- package/src/notch.mjs +154 -0
- package/src/pager.mjs +178 -0
- package/src/paths.mjs +13 -1
- package/src/plans.mjs +10 -2
- package/src/registry.mjs +110 -0
- package/src/runtime/discharge.mjs +1 -1
- package/src/runtime/provider.mjs +10 -7
- package/src/runtime/simple-cage.mjs +18 -9
- package/src/runtime/sql-acceptance-lane.mjs +1 -1
- package/src/session-host.mjs +8 -6
- package/src/sessions.mjs +168 -0
- package/src/setup.mjs +494 -0
- package/src/speaker.mjs +65 -0
- package/src/statements.mjs +113 -0
- package/src/substrate.mjs +44 -0
- package/src/successor.mjs +1 -1
- package/src/traces.mjs +8 -8
- package/src/uninstall.mjs +10 -2
- package/src/verifier.mjs +135 -47
- package/src/verify-dispatch.mjs +169 -0
- package/src/welcome.mjs +32 -0
- package/src/wire.mjs +64 -0
- package/src/workspace-resolver.mjs +178 -0
- package/src/workspace.mjs +16 -5
- package/vendor/ddl/001_core.sql +1 -1
- package/vendor/ddl/004_delegation.sql +1 -1
- package/vendor/ddl/006_dependency.sql +1 -1
- package/vendor/ddl/008_effect_receipt.sql +1 -1
- package/vendor/ddl/009_verified_edge.sql +1 -1
- package/vendor/ddl/011_confirm.sql +2 -2
- package/vendor/ddl/manifest.json +8 -8
- package/assets/handoff-splash.png +0 -0
- package/src/harness.mjs +0 -271
|
Binary file
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict/>
|
|
7
|
+
<key>files2</key>
|
|
8
|
+
<dict/>
|
|
9
|
+
<key>rules</key>
|
|
10
|
+
<dict>
|
|
11
|
+
<key>^Resources/</key>
|
|
12
|
+
<true/>
|
|
13
|
+
<key>^Resources/.*\.lproj/</key>
|
|
14
|
+
<dict>
|
|
15
|
+
<key>optional</key>
|
|
16
|
+
<true/>
|
|
17
|
+
<key>weight</key>
|
|
18
|
+
<real>1000</real>
|
|
19
|
+
</dict>
|
|
20
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
21
|
+
<dict>
|
|
22
|
+
<key>omit</key>
|
|
23
|
+
<true/>
|
|
24
|
+
<key>weight</key>
|
|
25
|
+
<real>1100</real>
|
|
26
|
+
</dict>
|
|
27
|
+
<key>^Resources/Base\.lproj/</key>
|
|
28
|
+
<dict>
|
|
29
|
+
<key>weight</key>
|
|
30
|
+
<real>1010</real>
|
|
31
|
+
</dict>
|
|
32
|
+
<key>^version.plist$</key>
|
|
33
|
+
<true/>
|
|
34
|
+
</dict>
|
|
35
|
+
<key>rules2</key>
|
|
36
|
+
<dict>
|
|
37
|
+
<key>.*\.dSYM($|/)</key>
|
|
38
|
+
<dict>
|
|
39
|
+
<key>weight</key>
|
|
40
|
+
<real>11</real>
|
|
41
|
+
</dict>
|
|
42
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
43
|
+
<dict>
|
|
44
|
+
<key>omit</key>
|
|
45
|
+
<true/>
|
|
46
|
+
<key>weight</key>
|
|
47
|
+
<real>2000</real>
|
|
48
|
+
</dict>
|
|
49
|
+
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
|
50
|
+
<dict>
|
|
51
|
+
<key>nested</key>
|
|
52
|
+
<true/>
|
|
53
|
+
<key>weight</key>
|
|
54
|
+
<real>10</real>
|
|
55
|
+
</dict>
|
|
56
|
+
<key>^.*</key>
|
|
57
|
+
<true/>
|
|
58
|
+
<key>^Info\.plist$</key>
|
|
59
|
+
<dict>
|
|
60
|
+
<key>omit</key>
|
|
61
|
+
<true/>
|
|
62
|
+
<key>weight</key>
|
|
63
|
+
<real>20</real>
|
|
64
|
+
</dict>
|
|
65
|
+
<key>^PkgInfo$</key>
|
|
66
|
+
<dict>
|
|
67
|
+
<key>omit</key>
|
|
68
|
+
<true/>
|
|
69
|
+
<key>weight</key>
|
|
70
|
+
<real>20</real>
|
|
71
|
+
</dict>
|
|
72
|
+
<key>^Resources/</key>
|
|
73
|
+
<dict>
|
|
74
|
+
<key>weight</key>
|
|
75
|
+
<real>20</real>
|
|
76
|
+
</dict>
|
|
77
|
+
<key>^Resources/.*\.lproj/</key>
|
|
78
|
+
<dict>
|
|
79
|
+
<key>optional</key>
|
|
80
|
+
<true/>
|
|
81
|
+
<key>weight</key>
|
|
82
|
+
<real>1000</real>
|
|
83
|
+
</dict>
|
|
84
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
85
|
+
<dict>
|
|
86
|
+
<key>omit</key>
|
|
87
|
+
<true/>
|
|
88
|
+
<key>weight</key>
|
|
89
|
+
<real>1100</real>
|
|
90
|
+
</dict>
|
|
91
|
+
<key>^Resources/Base\.lproj/</key>
|
|
92
|
+
<dict>
|
|
93
|
+
<key>weight</key>
|
|
94
|
+
<real>1010</real>
|
|
95
|
+
</dict>
|
|
96
|
+
<key>^[^/]+$</key>
|
|
97
|
+
<dict>
|
|
98
|
+
<key>nested</key>
|
|
99
|
+
<true/>
|
|
100
|
+
<key>weight</key>
|
|
101
|
+
<real>10</real>
|
|
102
|
+
</dict>
|
|
103
|
+
<key>^embedded\.provisionprofile$</key>
|
|
104
|
+
<dict>
|
|
105
|
+
<key>weight</key>
|
|
106
|
+
<real>20</real>
|
|
107
|
+
</dict>
|
|
108
|
+
<key>^version\.plist$</key>
|
|
109
|
+
<dict>
|
|
110
|
+
<key>weight</key>
|
|
111
|
+
<real>20</real>
|
|
112
|
+
</dict>
|
|
113
|
+
</dict>
|
|
114
|
+
</dict>
|
|
115
|
+
</plist>
|
package/notch/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Oathe Notch
|
|
2
|
+
|
|
3
|
+
The quiet glass. A macOS island that shows your durable work — and otherwise you
|
|
4
|
+
shouldn't know it's there.
|
|
5
|
+
|
|
6
|
+
Three states, nothing else:
|
|
7
|
+
|
|
8
|
+
- **rest** — literally nothing: dissolved into the MacBook's camera housing, or a
|
|
9
|
+
small sliver on external displays. Hover peeks a lock and how many tasks you hold.
|
|
10
|
+
- **event** — one pushed line, only when something happened (`🔒 1 unclaimed task
|
|
11
|
+
expiring`). Amber persists until seen; receipts show once and fade.
|
|
12
|
+
- **open** — click: work in motion. One row per live claim — task, the surface
|
|
13
|
+
speaking on it, the age of its last word. A row expands to its last progress and
|
|
14
|
+
home, with one act: `continue ↗` (copies `continue <task>`, opens the folder).
|
|
15
|
+
The sheet is Liquid Glass on macOS 26, the island's own black before that.
|
|
16
|
+
|
|
17
|
+
Drag it anywhere; it snaps to the nearest edge of any display and remembers its seat
|
|
18
|
+
(side docks lie vertical). Right-click: Reset Position, Start at Login, Quit.
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
The package computes, the notch renders. This app contains **zero business logic**.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
speech acts (claim · statement · done · yield · pickup · verify)
|
|
26
|
+
│ one pg_notify per successful write ("the wire")
|
|
27
|
+
▼
|
|
28
|
+
Postgres (oathe's local substrate)
|
|
29
|
+
▲ LISTEN
|
|
30
|
+
│
|
|
31
|
+
`oathe notch --serve` ← the feed: recomputes a frame per event + heartbeat
|
|
32
|
+
│ ndjson frames on stdout {push, breaches, motion, idle, sections, receipt?}
|
|
33
|
+
▼
|
|
34
|
+
OatheNotch.app ← this repo: supervises the feed child, renders frames
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
One file per concern:
|
|
38
|
+
|
|
39
|
+
| File | Owns |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `OatheNotchApp.swift` | bootstrap; launchd owns the process, the app owns its feed child |
|
|
42
|
+
| `Feed.swift` | frame decoding + feed supervision (restart with backoff; failures are typed amber lines, never silence) |
|
|
43
|
+
| `NotchModel.swift` | the state machine (motion-free) |
|
|
44
|
+
| `NotchView.swift` | the glass (geometry hugs content) |
|
|
45
|
+
| `NotchPanel.swift` | the window: seat, pointer arming, drag + snap — the only frame owner |
|
|
46
|
+
| `DockAnchor.swift` | where the island lives; persists; `clear()` goes home |
|
|
47
|
+
| `Theme.swift` | every token, named once — read its taxonomy header before adding a constant |
|
|
48
|
+
|
|
49
|
+
## The two scars (read before touching motion)
|
|
50
|
+
|
|
51
|
+
1. **The freeze** — never animate window frames from state changes; overlapping
|
|
52
|
+
animator groups wedge the panel. Content animates; the window holds still.
|
|
53
|
+
2. **The oscillation** — hover must never change window geometry; a frame that flees
|
|
54
|
+
the pointer flickers forever and can't be clicked.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
The notch ships with `@oathe/oathe` — the npm tarball carries the built app (prepack
|
|
59
|
+
builds it), and on macOS `oathe init` writes + bootstraps its LaunchAgent for everyone;
|
|
60
|
+
`oathe uninstall` boots it out and removes exactly what init recorded. No opt-in, no
|
|
61
|
+
extra step. `oathe config notchApp <path> --global` overrides the packaged app (a source
|
|
62
|
+
checkout that hasn't run `./make-app.sh` gets an honest `notch-binary-missing` row).
|
|
63
|
+
|
|
64
|
+
## Build from source
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
./make-app.sh # swift build + assemble "Oathe Notch.app" (ad-hoc signed)
|
|
68
|
+
oathe init # re-seats the LaunchAgent on the fresh build
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Requires macOS 14+, Swift toolchain, and [oathe](https://github.com/oathe-ai/oathe)
|
|
72
|
+
with its local substrate (`oathe init`).
|
|
73
|
+
|
|
74
|
+
## Platforms
|
|
75
|
+
|
|
76
|
+
macOS 14+ only, Apple Silicon and Intel (the shipped app is a universal binary). The
|
|
77
|
+
glass is native AppKit; everything beneath it is platform-neutral — `oathe notch
|
|
78
|
+
--serve` streams plain ndjson frames, so a Windows or Linux notch is a renderer plus
|
|
79
|
+
its own startup wiring, no substrate or wire changes. On other platforms `oathe init`
|
|
80
|
+
wires nothing and says nothing: there is nothing for the user to do.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
Apache-2.0, as the rest of the oathe repository.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
TBD — follows the oathe project's licensing decision.
|
package/package.json
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oathe/oathe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
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
6
|
"engines": {
|
|
7
|
-
"node": ">=22"
|
|
7
|
+
"node": ">=22.5.0"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"oathe": "bin/oathe.mjs"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "npm run test:unit && npm run test:heavy",
|
|
14
|
+
"test:unit": "node --test tests/activation.test.mjs tests/atif.test.mjs tests/blocks.test.mjs tests/board-render.test.mjs tests/config.test.mjs tests/cursor-harness.test.mjs tests/discharge.test.mjs tests/fslock.test.mjs tests/harness-contract.test.mjs tests/harness-docs.test.mjs tests/harness-docs-drift.test.mjs tests/harness.test.mjs tests/home.test.mjs tests/horizon-census.test.mjs tests/manifest.test.mjs tests/mcp-connection.test.mjs tests/notch.test.mjs tests/packaging.test.mjs tests/paths.test.mjs tests/registry.test.mjs tests/runtime-provider.test.mjs tests/sessions.test.mjs tests/setup.test.mjs tests/speaker.test.mjs tests/successor.test.mjs tests/traces.test.mjs tests/ux-contract.test.mjs tests/verify-dispatch.test.mjs tests/welcome.test.mjs tests/workspace-resolver.test.mjs tests/workspace.test.mjs",
|
|
15
|
+
"test:heavy": "node --test --test-concurrency=2 tests/amend.test.mjs tests/cli.test.mjs tests/harness-install-contract.test.mjs tests/harness-live-contract.test.mjs tests/init.test.mjs tests/integration.test.mjs tests/launch.test.mjs tests/oathe-tools.test.mjs tests/pager.test.mjs tests/plugin.test.mjs tests/session-host.test.mjs tests/simple-cage.test.mjs tests/sql-acceptance-lane.test.mjs tests/substrate.test.mjs tests/vendor-scripts.test.mjs tests/verifier.test.mjs",
|
|
16
|
+
"lint": "npx -y eslint@10.9.1 .",
|
|
17
|
+
"pack:dry-run": "npm pack --dry-run --ignore-scripts",
|
|
18
|
+
"prepack": "node scripts/pack-notch.mjs",
|
|
14
19
|
"link-runtime": "node scripts/link-runtime.mjs",
|
|
15
20
|
"vendor-ddl": "node scripts/vendor-ddl.mjs",
|
|
21
|
+
"live-contract": "node scripts/harness-live-contract.mjs",
|
|
22
|
+
"install-contract": "node scripts/harness-install-contract.mjs",
|
|
23
|
+
"harness-docs-drift": "node scripts/harness-docs-drift.mjs",
|
|
24
|
+
"harness-docs-lock": "node scripts/harness-docs-drift.mjs --lock",
|
|
16
25
|
"marker-scan": "node scripts/marker-scan.mjs",
|
|
17
|
-
"pack:dry-run": "npm pack --dry-run --ignore-scripts",
|
|
18
26
|
"ci:policy": "node scripts/ci/check-workflows.mjs"
|
|
19
27
|
},
|
|
20
28
|
"license": "Apache-2.0",
|
|
@@ -33,6 +41,7 @@
|
|
|
33
41
|
"src/",
|
|
34
42
|
"plugin/",
|
|
35
43
|
"vendor/",
|
|
44
|
+
"notch/Oathe Notch.app",
|
|
36
45
|
"docs/PRIVACY.md",
|
|
37
46
|
"LICENSE",
|
|
38
47
|
"NOTICE",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oathe",
|
|
3
3
|
"displayName": "Oathe",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
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
6
|
"author": {
|
|
7
7
|
"name": "Oathe"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "oathe",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"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.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Oathe"
|
|
7
|
+
},
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"mcpServers": {
|
|
10
|
+
"oathe": {
|
|
11
|
+
"command": "oathe",
|
|
12
|
+
"args": [
|
|
13
|
+
"mcp"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"hooks": {
|
|
18
|
+
"hooks": {
|
|
19
|
+
"sessionStart": [
|
|
20
|
+
{
|
|
21
|
+
"command": "oathe hook render-board"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"stop": [
|
|
25
|
+
{
|
|
26
|
+
"command": "oathe hook heartbeat"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"preCompact": [
|
|
30
|
+
{
|
|
31
|
+
"command": "oathe hook frame-note"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/plugin/.mcp.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Verify a task's asserted completion — optionally on a specific engine (claude | codex | cursor)
|
|
3
|
+
argument-hint: <task-id> [engine]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run verification for the named task with the `oathe_verify` MCP tool.
|
|
7
|
+
|
|
8
|
+
Arguments: `$ARGUMENTS` — the first word is the task id; the optional second word is the
|
|
9
|
+
engine to judge with (`claude`, `codex`, or `cursor` — any harness CLI present on this
|
|
10
|
+
machine can verify). Passing an engine is how you retry a STALLED verification on a
|
|
11
|
+
different engine after an outage (e.g. a usage limit): the failed run already released its
|
|
12
|
+
claim and recorded the failure, so the retry claims cleanly.
|
|
13
|
+
|
|
14
|
+
Call `oathe_verify` with `{task_id, engine?}`. It returns immediately — verification runs
|
|
15
|
+
in a detached background process. Report to the user exactly what the response says: the
|
|
16
|
+
verdict lands on the board; a rejection reopens the task with the reason recorded on the
|
|
17
|
+
verify-task's completion statement; the engine log path is in the response. Do not wait or
|
|
18
|
+
poll unless the user asks.
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
5
|
import { failSoft } from './lib.mjs';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Custody is the PRINCIPAL's, not the folder's (R-HOME-BOARD): every claim this principal
|
|
8
|
+
// actively holds gets the note, wherever the task is homed.
|
|
9
|
+
await failSoft(async ({ substrate, identity }) => {
|
|
8
10
|
const { rows } = await substrate.query(
|
|
9
11
|
`SELECT work_claim_id, task_id FROM cell.work_claim
|
|
10
|
-
WHERE org_id = $1 AND principal_id = $2 AND state = 'active'
|
|
11
|
-
[identity.orgId, identity.principalId
|
|
12
|
+
WHERE org_id = $1 AND principal_id = $2 AND state = 'active'`,
|
|
13
|
+
[identity.orgId, identity.principalId]);
|
|
12
14
|
for (const claim of rows) {
|
|
13
15
|
await substrate.query(
|
|
14
16
|
`INSERT INTO cell.agent_statement (statement_id, org_id, task_id, work_claim_id,
|
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
// ownership_valid_until: session liveness is not an organizational act (R1, correction
|
|
5
5
|
// packet 2026-08-26); the horizon is set at claim time by the substrate's claim verb.
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { failSoft } from './lib.mjs';
|
|
9
|
-
import {
|
|
7
|
+
import { linkTrace } from '../../src/statements.mjs';
|
|
8
|
+
import { failSoft, ensureSessionRegistered } from './lib.mjs';
|
|
9
|
+
import { claimIntervals } from '../../src/atif.mjs';
|
|
10
|
+
import { projectorFor } from '../../src/harnesses/catalog.mjs';
|
|
10
11
|
|
|
11
|
-
await failSoft(async ({ substrate,
|
|
12
|
+
await failSoft(async ({ substrate, identity, session, paths, workspace }) => {
|
|
13
|
+
// The session's liveness signal — independent of trace linkage (a planning-only session
|
|
14
|
+
// still converges) and fail-soft on its own.
|
|
15
|
+
await ensureSessionRegistered({ session, paths, workspace });
|
|
12
16
|
if (!session?.transcriptPath) return; // no identity handed to this hook — nothing to link
|
|
13
17
|
// R3 (§5): evidence is claim-specific and interval-specific. The session's own structured
|
|
14
18
|
// trace names the tasks it ACTED on (the projector's claim_events); only those claims get
|
|
@@ -16,7 +20,7 @@ await failSoft(async ({ substrate, workspace, identity, config, session }) => {
|
|
|
16
20
|
// a planning-only session leaves no claim evidence.
|
|
17
21
|
let touched;
|
|
18
22
|
try {
|
|
19
|
-
const trajectory = projectorFor(session.transcriptPath).project(session.transcriptPath);
|
|
23
|
+
const trajectory = (await projectorFor(session.transcriptPath)).project(session.transcriptPath);
|
|
20
24
|
touched = new Set(claimIntervals(trajectory).map((i) => i.task_id));
|
|
21
25
|
} catch {
|
|
22
26
|
return; // fail-soft: an unreadable or unprojectable trace attributes nothing
|
|
@@ -25,25 +29,17 @@ await failSoft(async ({ substrate, workspace, identity, config, session }) => {
|
|
|
25
29
|
// Linkage covers ASSERTED claims too: a claim taken and completed inside a single turn has
|
|
26
30
|
// never seen a heartbeat while active — the turn-end hook is its only chance to leave the
|
|
27
31
|
// trace evidence the verifier will demand. (Settled claims are closed; nothing to link.)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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])]);
|
|
32
|
+
// Custody is the PRINCIPAL's, not the folder's (R-HOME-BOARD): a claim homed on another
|
|
33
|
+
// board is still this principal's, and the trace's own touched-set is what scopes linkage.
|
|
34
|
+
// The write wrapper already linked every claim SPOKEN through the tools (linkTrace at
|
|
35
|
+
// the act — the SPEAKER primitive); this turn-end sweep covers claims the transcript
|
|
36
|
+
// proves were WORKED without a substrate write this turn. Same writer, idempotent.
|
|
37
|
+
for (const taskId of touched) {
|
|
38
|
+
await linkTrace({
|
|
39
|
+
client: substrate,
|
|
40
|
+
identity,
|
|
41
|
+
taskId,
|
|
42
|
+
session: { sessionId: session.sessionId, transcriptPath: session.transcriptPath, harness: session.harness },
|
|
43
|
+
});
|
|
48
44
|
}
|
|
49
45
|
});
|
package/plugin/hooks/lib.mjs
CHANGED
|
@@ -3,37 +3,68 @@
|
|
|
3
3
|
//
|
|
4
4
|
// A hook must NEVER break a session: every entry point runs through failSoft, which turns any
|
|
5
5
|
// substrate absence into a quiet note (SessionStart) or silence (Stop/PreCompact) and exit 0.
|
|
6
|
+
// Payloads arrive in each harness's own dialect (Claude/Codex: `cwd`; Cursor:
|
|
7
|
+
// `workspace_roots[]`) — the catalog's dialect sniff normalizes them, and the reply speaks the
|
|
8
|
+
// same dialect back. A session with no resolvable workspace exits silently: there is no board
|
|
9
|
+
// to speak about, and hooks are the one sanctioned fail-soft surface.
|
|
10
|
+
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
6
13
|
|
|
7
14
|
import { Substrate } from '../../src/substrate.mjs';
|
|
8
|
-
import { buildPaths } from '../../src/paths.mjs';
|
|
9
|
-
import { workspaceRef } from '../../src/workspace.mjs';
|
|
15
|
+
import { buildPaths, homeOf } from '../../src/paths.mjs';
|
|
10
16
|
import { OatheConfig } from '../../src/config.mjs';
|
|
11
|
-
import { harnessForTracePath } from '../../src/traces.mjs';
|
|
12
|
-
import { launchedHarness } from '../../src/launch-env.mjs';
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
import { dialectFor, ownerOfTracePath } from '../../src/harnesses/catalog.mjs';
|
|
19
|
+
import { cwdDialect } from '../../src/harnesses/dialects.mjs';
|
|
20
|
+
import { WorkspaceResolver } from '../../src/workspace-resolver.mjs';
|
|
21
|
+
|
|
22
|
+
/** The hook's JSON input on stdin, whichever dialect the harness speaks. */
|
|
15
23
|
export async function readHookInput() {
|
|
16
24
|
let raw = '';
|
|
17
25
|
for await (const chunk of process.stdin) raw += chunk;
|
|
18
|
-
try { return JSON.parse(raw); } catch { return {}; }
|
|
26
|
+
const input = (() => { try { return JSON.parse(raw); } catch { return {}; } })();
|
|
27
|
+
// Drift monitors: with OATHE_HOOK_CAPTURE_DIR set, the RAW payload is written before any
|
|
28
|
+
// normalization — the live lane compares what the harness actually sends against the pinned
|
|
29
|
+
// fixtures. Off by default; a capture failure never costs the session (fail-soft surface).
|
|
30
|
+
const captureDir = process.env.OATHE_HOOK_CAPTURE_DIR;
|
|
31
|
+
if (captureDir) {
|
|
32
|
+
try {
|
|
33
|
+
fs.mkdirSync(captureDir, { recursive: true });
|
|
34
|
+
fs.writeFileSync(path.join(captureDir, `${input.hook_event_name ?? 'unknown'}-${Date.now()}.json`), raw);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
process.stderr.write(`oathe hook: capture ${String(e?.message || e)}\n`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return input;
|
|
19
40
|
}
|
|
20
41
|
|
|
21
|
-
export function buildHookContext(input, env = process.env) {
|
|
42
|
+
export async function buildHookContext(input, env = process.env) {
|
|
22
43
|
const paths = buildPaths(env);
|
|
23
|
-
const
|
|
44
|
+
const dialect = dialectFor(input) ?? cwdDialect;
|
|
45
|
+
const normalized = dialect.normalizePayload(input ?? {});
|
|
46
|
+
// A payload naming a directory is described outright; one without falls to the resolution
|
|
47
|
+
// ladder (env vars, guarded cwd). Either way the facts (ref, synthetic) come from the one
|
|
48
|
+
// describer. An unresolvable session throws OATHE_WORKSPACE_UNRESOLVED — failSoft exits silently.
|
|
49
|
+
const home = homeOf(env);
|
|
50
|
+
const place = normalized.cwd
|
|
51
|
+
? WorkspaceResolver.describe({ dir: normalized.cwd, home })
|
|
52
|
+
: await new WorkspaceResolver({ env, home }).resolve();
|
|
53
|
+
const cwd = place.dir;
|
|
24
54
|
const config = new OatheConfig({ env, cwd });
|
|
25
|
-
// The session identity
|
|
26
|
-
const session =
|
|
55
|
+
// The session identity the harness hands every hook — the trace linkage rides on it.
|
|
56
|
+
const session = normalized.sessionId
|
|
27
57
|
? {
|
|
28
|
-
sessionId:
|
|
29
|
-
transcriptPath:
|
|
30
|
-
harness:
|
|
58
|
+
sessionId: normalized.sessionId,
|
|
59
|
+
transcriptPath: normalized.transcriptPath,
|
|
60
|
+
harness: ownerOfTracePath(normalized.transcriptPath ?? ''),
|
|
31
61
|
}
|
|
32
62
|
: null;
|
|
33
63
|
return {
|
|
34
64
|
session,
|
|
35
65
|
substrate: new Substrate({ database: config.get('db'), paths, env, config }),
|
|
36
|
-
workspace:
|
|
66
|
+
workspace: place.ref,
|
|
67
|
+
synthetic: place.synthetic, // R-BOARD-SCOPE: a staging dir serves the full board
|
|
37
68
|
identity: {
|
|
38
69
|
orgId: config.get('org'),
|
|
39
70
|
principalId: config.get('principal') || env.USER || 'operator',
|
|
@@ -41,41 +72,73 @@ export function buildHookContext(input, env = process.env) {
|
|
|
41
72
|
},
|
|
42
73
|
config,
|
|
43
74
|
cwd,
|
|
75
|
+
dialect,
|
|
76
|
+
paths,
|
|
77
|
+
env,
|
|
44
78
|
};
|
|
45
79
|
}
|
|
46
80
|
|
|
47
81
|
/**
|
|
48
|
-
* The SessionStart
|
|
49
|
-
*
|
|
50
|
-
|
|
82
|
+
* The SessionStart reply in the session's own dialect: `context` reaches the MODEL, `message`
|
|
83
|
+
* is the user-visible line (dialects without a message channel carry context only).
|
|
84
|
+
*/
|
|
85
|
+
export function emitSessionStart({ context, message, dialect = cwdDialect }) {
|
|
86
|
+
process.stdout.write(dialect.formatSessionStart({ context, message }));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The session's liveness signal — SessionStart and the heartbeat both speak it, so a living
|
|
91
|
+
* session is never invisible (a pre-feature or resumed session converges at its next turn).
|
|
92
|
+
* The ps walk rides the facts thunk: paid only when the registry actually (re)registers.
|
|
93
|
+
* Fail-soft on its own: a broken registry costs the facts, never the session.
|
|
51
94
|
*/
|
|
52
|
-
export function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
95
|
+
export async function ensureSessionRegistered({ session, paths, workspace = undefined }) {
|
|
96
|
+
try {
|
|
97
|
+
if (!session?.sessionId) return;
|
|
98
|
+
const { SessionRegistry, processAncestry, nearestAppBundle } = await import('../../src/sessions.mjs');
|
|
99
|
+
const { ownedAncestorIndex } = await import('../../src/harnesses/catalog.mjs');
|
|
100
|
+
// The row describes THE HARNESS PROCESS, not whatever interposer spawned the hook
|
|
101
|
+
// (cursor-agent runs hooks through a short-lived /bin/zsh — registering the shell's pid
|
|
102
|
+
// would sweep the session the moment the shell exits). Walk up to the nearest
|
|
103
|
+
// adapter-owned ancestor; a chain with none (fixtures, bare runners) keeps the ppid.
|
|
104
|
+
const walk = processAncestry({ pid: process.ppid });
|
|
105
|
+
const owned = ownedAncestorIndex(walk);
|
|
106
|
+
const ancestry = owned <= 0 ? walk : walk.slice(owned);
|
|
107
|
+
await new SessionRegistry({ sessionsPath: paths.sessionsPath }).ensure({
|
|
108
|
+
sessionId: session.sessionId,
|
|
109
|
+
pid: ancestry[0]?.pid ?? process.ppid,
|
|
110
|
+
facts: () => ({
|
|
111
|
+
ancestry,
|
|
112
|
+
app: nearestAppBundle(ancestry),
|
|
113
|
+
transcriptPath: session.transcriptPath ?? undefined,
|
|
114
|
+
workspace,
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
} catch (e) {
|
|
118
|
+
process.stderr.write(`oathe hook: sessions ${String(e?.message || e)}\n`);
|
|
119
|
+
}
|
|
57
120
|
}
|
|
58
121
|
|
|
59
122
|
/**
|
|
60
|
-
* Run `fn`; on
|
|
61
|
-
*
|
|
62
|
-
*
|
|
123
|
+
* Run `fn`; on failure print `quietNote` (when given) as a visible session-load line and exit 0
|
|
124
|
+
* regardless. The board being unavailable is information for the session, never an error that
|
|
125
|
+
* blocks it — and a session with no resolvable workspace has no board to mention at all.
|
|
63
126
|
*/
|
|
64
127
|
export async function failSoft(fn, { quietNote = null } = {}) {
|
|
65
|
-
// The opt-in gate: the plugin reaches every session on the machine, but only a session the
|
|
66
|
-
// oathe launcher started carries the marker. Everything else is a silent noop — no output,
|
|
67
|
-
// no substrate contact — because that session never asked to be on the board.
|
|
68
|
-
if (!launchedHarness()) process.exit(0);
|
|
69
128
|
let substrate = null;
|
|
129
|
+
let dialect = cwdDialect;
|
|
70
130
|
try {
|
|
71
131
|
const input = await readHookInput();
|
|
72
|
-
|
|
132
|
+
dialect = dialectFor(input) ?? cwdDialect;
|
|
133
|
+
const ctx = await buildHookContext(input);
|
|
73
134
|
substrate = ctx.substrate;
|
|
74
135
|
await fn(ctx, input);
|
|
75
136
|
} catch (e) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
137
|
+
if (e?.code !== 'OATHE_WORKSPACE_UNRESOLVED') {
|
|
138
|
+
const detail = String(e?.message || e);
|
|
139
|
+
if (quietNote) emitSessionStart({ context: quietNote, message: `${quietNote} (${detail.slice(0, 120)})`, dialect });
|
|
140
|
+
process.stderr.write(`oathe hook: ${detail}\n`);
|
|
141
|
+
}
|
|
79
142
|
} finally {
|
|
80
143
|
if (substrate) await substrate.close().catch(() => {});
|
|
81
144
|
}
|
|
@@ -1,11 +1,51 @@
|
|
|
1
|
-
// SessionStart — the board
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// SessionStart — activation + the board. Opening a session on a folder ACTIVATES its
|
|
2
|
+
// workspace (central registry row + the context-file fences, through the ONE writer in
|
|
3
|
+
// src/activation.mjs, disclosed in the render) and then delivers the board twice over: the
|
|
4
|
+
// full list as additional context for the MODEL, one visible line for the USER — each in the
|
|
5
|
+
// session's own dialect. Activation failing must never cost the session its board: the
|
|
6
|
+
// failure is reported on stderr and the render proceeds (hooks are the sanctioned fail-soft).
|
|
4
7
|
|
|
5
|
-
import { failSoft, emitSessionStart } from './lib.mjs';
|
|
8
|
+
import { failSoft, emitSessionStart, ensureSessionRegistered } from './lib.mjs';
|
|
6
9
|
import { renderBoard } from '../../src/board-render.mjs';
|
|
10
|
+
import { WorkspaceRegistry } from '../../src/registry.mjs';
|
|
7
11
|
|
|
8
|
-
await failSoft(async ({ substrate, workspace, identity, config }) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
12
|
+
await failSoft(async ({ substrate, workspace, synthetic, identity, config, cwd, dialect, paths, env, session }) => {
|
|
13
|
+
const registry = new WorkspaceRegistry({ registryPath: paths.registryPath });
|
|
14
|
+
let disclosed = null;
|
|
15
|
+
try {
|
|
16
|
+
const [{ activateWorkspace }, { InstallManifest }, { packageVersion }] = await Promise.all([
|
|
17
|
+
import('../../src/activation.mjs'), import('../../src/manifest.mjs'), import('../../src/context.mjs'),
|
|
18
|
+
]);
|
|
19
|
+
const manifest = InstallManifest.load({ manifestPath: paths.manifestPath, backupsDir: paths.backupsDir });
|
|
20
|
+
const out = await activateWorkspace({
|
|
21
|
+
cwd, env, manifest, registry, config, version: packageVersion(paths), source: 'hook:session-start',
|
|
22
|
+
});
|
|
23
|
+
// Disclose only when something was actually written — an unchanged fence needs no line,
|
|
24
|
+
// and autoActivate=false registers quietly (the user's own explicit choice).
|
|
25
|
+
disclosed = out.actions.some((a) => a.changed) ? out.disclosed : null;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
process.stderr.write(`oathe hook: activation ${String(e?.message || e)}\n`);
|
|
28
|
+
}
|
|
29
|
+
// Session liveness: the hook's ppid IS the harness process — the shared convergence
|
|
30
|
+
// signal registers its facts so the notch can meet the living process behind a claim.
|
|
31
|
+
await ensureSessionRegistered({ session, paths, workspace });
|
|
32
|
+
// R-PAGER: the breach digest is computed apart from the board, and a failure there is
|
|
33
|
+
// reported on stderr while the board still renders — the digest is a courtesy, the board
|
|
34
|
+
// is the session's contract.
|
|
35
|
+
let breaches = [];
|
|
36
|
+
try {
|
|
37
|
+
const { Pager } = await import('../../src/pager.mjs');
|
|
38
|
+
breaches = await new Pager({ client: substrate, identity, config, registry }).breaches();
|
|
39
|
+
} catch (e) {
|
|
40
|
+
process.stderr.write(`oathe hook: pager ${String(e?.message || e)}\n`);
|
|
41
|
+
}
|
|
42
|
+
const { context, message } = await renderBoard({ client: substrate, identity, workspace, config, synthetic, breaches });
|
|
43
|
+
// R-QUIET: the board message is breaches-or-silence; a real write's disclosure still speaks
|
|
44
|
+
// (a receipt, printed once) even when the board itself has nothing to push.
|
|
45
|
+
const visible = [message, disclosed].filter(Boolean).join('\n') || null;
|
|
46
|
+
emitSessionStart({
|
|
47
|
+
context: disclosed ? `${context}\n\n_${disclosed}_` : context,
|
|
48
|
+
message: visible,
|
|
49
|
+
dialect,
|
|
50
|
+
});
|
|
11
51
|
}, { quietNote: 'Oathe board unavailable — substrate not initialized; run `oathe init`' });
|