From 07cceeeb87c5dfcf9724c51878ec389dd64d4076 Mon Sep 17 00:00:00 2001 From: Sunil Srivatsa Date: Tue, 10 Nov 2026 14:47:28 -0800 Subject: [PATCH 1/3] feat!: report each OMP session to SidePulse's program-status socket SidePulse removed the hook-event sockets tern-sidepulse 0.1.0 wrote to (inteliwear/sidepulse#72, merged 2026-11-10 as ad4a5217; SidePulse desktop installs from main, so `sidepulse update` ships it). 0.2.0 talks only to the new program-status protocol and shows one SidePulse row per OMP session, named after its tab or pane. - transport.py: SidePulseTransport sends one acknowledged program_status report per row (at most 32, most urgent first) under a salted scope, clears rows that leave, refreshes active rows every 300 s, backs off 2-30 s, retries at once when a socket appears, and resubmits rows (except done) when SidePulse restarts. A write-ahead ledger of scope hashes lets the next coordinator clear a crashed one's rows after one lease, overwriting rows that are still open instead of clearing and re-adding them. Rejections log fixed text only. - Labels go to SidePulse by default; `"labels": false` in config.json sends an empty title and "OMP in Tern" instead. cwd is never read or sent. - config `program_sockets`, TERN_SIDEPULSE_PROGRAM_SOCKETS and --program-socket replace the ui/service socket settings; doctor's `receiver` check tells a pre-#72 SidePulse to `sidepulse update`. - Tests: transport units, doctor checks, migrated coordinator and subprocess suites, and a contract test against SidePulse's own server (CI pins ad4a5217). Docs and site describe the new contract and the laptop checks. BREAKING CHANGE: requires a SidePulse build that includes inteliwear/sidepulse#72; use tern-sidepulse 0.1.0 with older SidePulse. --- .github/workflows/ci.yml | 19 + CHANGELOG.md | 10 +- CONTRIBUTING.md | 42 ++- README.md | 78 ++-- SECURITY.md | 22 +- docs/compatibility.md | 106 +++--- plugin.toml | 2 +- site/index.html | 63 ++-- site/llms.txt | 4 +- tern_sidepulse/__init__.py | 2 +- tern_sidepulse/cli.py | 19 +- tern_sidepulse/client.py | 10 +- tern_sidepulse/coordinator.py | 16 +- tern_sidepulse/doctor.py | 38 +- tern_sidepulse/paths.py | 26 +- tern_sidepulse/server.py | 18 +- tern_sidepulse/storage.py | 15 +- tern_sidepulse/transport.py | 554 +++++++++++++++++------------ tests/fixtures/sidepulse_probe.py | 47 --- tests/fixtures/sidepulse_server.py | 26 ++ tests/helpers.py | 141 +++++--- tests/test_cli.py | 54 +-- tests/test_doctor.py | 65 ++++ tests/test_e2e.py | 119 ++++--- tests/test_fencing.py | 7 +- tests/test_leases.py | 61 ++-- tests/test_notices.py | 2 +- tests/test_paths.py | 51 ++- tests/test_privacy.py | 311 +++++++++------- tests/test_reducer.py | 11 +- tests/test_rows.py | 28 +- tests/test_server.py | 78 ++-- tests/test_sidepulse_contract.py | 195 ++++++++-- tests/test_transport.py | 527 +++++++++++++++------------ window.luau | 2 +- 35 files changed, 1666 insertions(+), 1103 deletions(-) delete mode 100644 tests/fixtures/sidepulse_probe.py create mode 100644 tests/fixtures/sidepulse_server.py create mode 100644 tests/test_doctor.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fe1adc..512afa2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,3 +40,22 @@ jobs: env: LUAU: ${{ github.workspace }}/luau-bin/luau TERN_SIDEPULSE_REQUIRE_LUAU: "1" + + sidepulse-contract: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check out SidePulse at the verified revision (the inteliwear/sidepulse#72 merge) + uses: actions/checkout@v4 + with: + repository: inteliwear/sidepulse + ref: ad4a5217fd3a833cfa2a12e1eaf055f22948cd53 + path: sidepulse + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + - run: python -m unittest tests.test_sidepulse_contract -v + env: + SIDEPULSE_SRC: ${{ github.workspace }}/sidepulse/src + TERN_SIDEPULSE_REQUIRE_CONTRACT: "1" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4858015..6b330af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog -## Unreleased +## 0.2.0 — Unreleased -- Per-pane rows in the coordinator (`tern_sidepulse/coordinator.py`, `tern_sidepulse/reducer.py`): observations are keyed by `(host, pane)` (`local`, or a remote host's `address`, `name`, or `id:`) and deduplicated across windows by mode priority (`blocked_error`, `waiting_for_input`, `working`, `completed`, `idle_ready`) and newest label, while the SidePulse hook-event transport continues to emit one combined session (`OMP in Tern`). -- In-memory session labels (`window.luau`, `tern_sidepulse/reducer.py`, `tests/test_privacy.py`, `tests/test_rows.py`): when a window has at least one OMP pane, `window.luau` reads `cx.session:panes()` and `cx.session:tabs()` at most once per 5 s pass and labels each OMP pane from its user-given tab name (`TabInfo.name`) or its own `PaneInfo.title` (cut to 256 UTF-8 bytes in the window and sanitized in the coordinator to at most 96 characters without control, surrogate, or private-use characters). Labels and host keys stay in coordinator memory only and never appear in `coordinator.log`, `doctor.json`, `bridge.py status`, coordinator acknowledgements, or the SidePulse payload (`status` and `doctor` report row counts and allow-listed diagnostic counters only). +- **Breaking requirement — SidePulse with `program_status` ([inteliwear/sidepulse#72](https://github.com/inteliwear/sidepulse/pull/72))**: Requires a SidePulse build installed or updated with `sidepulse update` on or after 2026-11-10 (merge commit `ad4a5217`). When an older SidePulse is present (`relay-events.sock` without `program-status.sock`), `tern-sidepulse: doctor` reports an error on `receiver` (`this SidePulse predates program status`) with the remedy `sidepulse update`. Use `tern-sidepulse` `0.1.0` for older SidePulse builds. +- SidePulse program-status transport (`tern_sidepulse/transport.py`, `tern_sidepulse/coordinator.py`, `tern_sidepulse/doctor.py`): replaces the 0.1.0 hook-event transport (`events.sock`, `relay-events.sock`, `UserPromptSubmit`/`Interrupt`/… hook-event lines, and the single combined `tern-sidepulse:` session) with `SidePulseTransport` over SidePulse's `program-status.sock` (`$XDG_STATE_HOME/sidepulse/agent-monitor/program-status.sock`, `~/.local/state/sidepulse/agent-monitor/program-status.sock`, or `/tmp/sidepulse-status-/.sock` when the `program-status.sock` path exceeds 96 bytes). Each OMP session is reported as its own row under salted scope `tern-sidepulse-<24 hex>` (`sha256(install_id NUL host NUL pane)[:24]`, salted by `install_id` from `identity.json`), mapped to states `working`, `blocked` (`waiting_for_input`), `error` (`blocked_error`), `done` (`completed`), `idle` (`idle_ready`), and `clear` across at most 32 rows (most urgent first). Unchanged rows are not resent; active rows (`working`, `blocked`, `error`) refresh every 300 s; retries reuse `request_id` with 2, 4, 8, 16, 30 s backoff and wake immediately when a socket appears or changes; SidePulse restarts resubmit every current row except `done` rows; and a scope ledger (`/program-scopes.json`, mode `0600`, salted scope hashes only) written before each scope's first report lets the next coordinator overwrite still-open panes in place and clear stale ones after a 15 s grace period following a crash. +- Per-pane rows and session labels (`window.luau`, `tern_sidepulse/coordinator.py`, `tern_sidepulse/reducer.py`, `tests/test_privacy.py`, `tests/test_rows.py`, `tests/test_transport.py`): observations are keyed by `(host, pane)` (`local`, or a remote host's `address`, `name`, or `id:`) and deduplicated across windows by mode priority (`blocked_error`, `waiting_for_input`, `working`, `completed`, `idle_ready`) and newest non-empty label. When a window has at least one OMP pane, `window.luau` reads `cx.session:panes()` and `cx.session:tabs()` at most once per 5 s pass and labels each OMP pane from its user-given tab name (`TabInfo.name`) or its own `PaneInfo.title` (cut to 256 UTF-8 bytes in the window and sanitized in the coordinator to at most 96 characters without control, surrogate, or private-use characters). Sanitized labels are sent to SidePulse in `context.title` by default (`"labels": false` in `/config.json` sends `"title": ""` and `"display_name": "OMP in Tern"` instead); host keys never appear outside coordinator memory, pane ids and host keys never leave the Mac (SidePulse reports and `program-scopes.json` carry salted scope hashes only), and labels never appear in `coordinator.log`, `doctor.json`, `bridge.py status`, coordinator replies, or `program-scopes.json`. +- Configuration, environment, CLI, and status updates (`tern_sidepulse/cli.py`, `tern_sidepulse/client.py`, `tern_sidepulse/doctor.py`): `/config.json` takes `program_sockets` (replacing `ui_sockets` and `service_sockets`, which are ignored if still present) and `labels` (`false` disables labels); `TERN_SIDEPULSE_PROGRAM_SOCKETS` replaces `TERN_SIDEPULSE_UI_SOCKETS` and `TERN_SIDEPULSE_SERVICE_SOCKETS`; `bridge.py coordinator --program-socket PATH` (repeatable) replaces `--ui-socket` and `--service-socket`; `doctor` replaces `receiver_ui` and `receiver_service` with `receiver` (plus `receiver_rejections` when SidePulse rejects a report) and shows `install …` on its `identity` check; and `status` drops `session_id` in favour of per-mode `rows` counts, `rows_total`, `rows_labelled`, `status.transport`, and `delivery = {"program_status": …}` in coordinator replies. - Snapshot budget and request limits (`window.luau`, `tern_sidepulse/limits.py`): the window keeps each encoded snapshot within 192 KiB by dropping labels and retrying once (`labels_dropped`), host keys are capped at 128 bytes in the window and 128 characters in the coordinator, and the coordinator request cap is raised from 256 KiB to 1 MiB. -- Headless Luau window harness (`tests/luau/`, `tests/test_luau_harness.py`, `.github/workflows/ci.yml`): runs the real `window.luau` under the `luau` 0.745 CLI across the backoff/interpreter/latch/role test drive (`drive_backoff.luau`, scenarios A–G), the label and host-key drive (`drive_labels.luau`, scenarios L1–L12), and the snapshot-budget drive (`drive_budget.luau`, scenarios B1–B3), bringing the suite to 155 unit and integration tests. +- Headless Luau window harness and contract checks (`tests/luau/`, `tests/test_luau_harness.py`, `tests/test_sidepulse_contract.py`, `.github/workflows/ci.yml`): runs the real `window.luau` under the `luau` 0.745 CLI across the backoff/interpreter/latch/role test drive (`drive_backoff.luau`, scenarios A–G), the label and host-key drive (`drive_labels.luau`, scenarios L1–L12), and the snapshot-budget drive (`drive_budget.luau`, scenarios B1–B3), and checks the `program_status` wire contract against SidePulse `ad4a5217`. ## 0.1.0 — 2026-11-05 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16fa121..626dfdc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,9 +19,9 @@ behavior claims are backed by evidence, privacy boundaries stay intact, and the `TERN_SIDEPULSE_REQUIRE_LUAU=1` to fail instead of skipping when `luau` is absent). An Oh My Pi session started at the repository root runs the same analysis while editing: [`.omp/lsp.json`](.omp/lsp.json) launches `luau-lsp lsp` with these definitions on the standard (non-Roblox) platform, for diagnostics and hover on `.luau` files. -- **Tern 0.9.12 on macOS**: required only for manual end-to-end checks against a live Tern window and SidePulse's agent - monitor (`events.sock` and `relay-events.sock`); see [`docs/compatibility.md`](docs/compatibility.md) for the probe - and integration checks. +- **Tern 0.9.12 or later on macOS**: required only for manual end-to-end checks against a live Tern window and SidePulse's + `program-status.sock` receiver; see [`docs/compatibility.md`](docs/compatibility.md) for the probe and integration + checks. - **Headless Chrome and `ffmpeg` (with `ffprobe` and `libx264`; `/opt/homebrew/bin/gifsicle` optional)**: required only when regenerating brand artwork (`assets/*.png`) or demo media (`docs/media/*`) with `scripts/render_assets.py`. @@ -34,8 +34,9 @@ python3 -B -m unittest discover -s tests -t . -v # -B keeps bytecode out of a luau-lsp analyze --definitions=types/tern.d.luau window.luau ``` -Set `SIDEPULSE_PYTHON` to a SidePulse interpreter (defaults to `~/.local/share/sidepulse/venv/bin/python` when present) -to run `tests/test_sidepulse_contract.py` against the installed SidePulse normalizer, and set +Set `SIDEPULSE_SRC=/src` to run the optional SidePulse contract test +(`SIDEPULSE_SRC=/src python3 -m unittest tests.test_sidepulse_contract`, skipped without it; CI +runs it against `inteliwear/sidepulse` at `ad4a5217` with `TERN_SIDEPULSE_REQUIRE_CONTRACT=1`), and set `TERN_SIDEPULSE_SLOW_TESTS=1` to include the 20 s default-limits timing test in `tests/test_e2e.py`. ## Working with a linked checkout @@ -57,22 +58,25 @@ to run `tests/test_sidepulse_contract.py` against the installed SidePulse normal ## Invariants and documentation standards 1. **Standard library only**: do not add third-party Python packages, external runtime tools, or network calls. -2. **Privacy invariants (`tests/test_privacy.py`, `tests/test_rows.py`)**: the window observer (`window.luau`) reads - only `pane`, `state`, `kind`, `program`, `host`, and `alive` from `cx.agents:list()`; `id`, `state`, `panes`, `kind`, - `address`, and `name` from `cx.hosts:list()`; `surface.role` from `cx.session:surface(pane, {nodes = 1, depth = 1})`; - and, at most once per 5 s pass when the window has at least one OMP pane, `pane`, `tab`, and `title` from - `cx.session:panes()` and `id` and `name` from `cx.session:tabs()`. Labels come only from user-given tab names - (`TabInfo.name`) and OMP panes' own `PaneInfo.title` (never `TabInfo.title`), and the plugin never reads working - directories, model names, commands, prompts, assistant text, tool arguments, or transcript paths. Labels and host - keys stay in the coordinator's memory only: they are never logged in `coordinator.log`, persisted to disk, returned - by `bridge.py status` or `doctor.json`, echoed in coordinator acknowledgements or rejections, or sent to SidePulse by - the hook-event transport. `tests/test_privacy.py` pins that sentinels in labels, host keys, and extra client fields - never leave the coordinator, `doctor.json` filters window diagnostics to allow-listed integer counters, and the - SidePulse socket payload's `line` object carries only its seven fixed status keys plus `"prompt"` on `working` - events (where `"prompt"` is always the constant `"OMP in Tern"`, never user prompt text or a pane label). +2. **Privacy invariants (`tests/test_privacy.py`, `tests/test_rows.py`, `tests/test_transport.py`)**: the window + observer (`window.luau`) reads only `pane`, `state`, `kind`, `program`, `host`, and `alive` from `cx.agents:list()`; + `id`, `state`, `panes`, `kind`, `address`, and `name` from `cx.hosts:list()`; `surface.role` from + `cx.session:surface(pane, {nodes = 1, depth = 1})`; and, at most once per 5 s pass when the window has at least one + OMP pane, `pane`, `tab`, and `title` from `cx.session:panes()` and `id` and `name` from `cx.session:tabs()`. Labels + come only from user-given tab names (`TabInfo.name`) and OMP panes' own `PaneInfo.title` (never `TabInfo.title`), + and the plugin never reads working directories (`cwd`), model names, commands, prompts, assistant text, tool + arguments, or transcript paths. By default, sanitized labels are sent only to SidePulse in `program_status` reports + (`context.title`), and setting `"labels": false` in `/config.json` sends `"title": ""` and + `"display_name": "OMP in Tern"` instead. Host keys never appear outside coordinator memory, and pane ids and host + keys never leave the Mac: SidePulse scopes (`tern-sidepulse-<24 hex>`), `context.session_id`, and the write-ahead + scope ledger (`program-scopes.json`) hold only salted `sha256(install_id NUL host NUL pane)[:24]` hashes (`install_id` + from `identity.json`; local `status` and `doctor.json` list pane ids of active outcome notices). Labels and host keys never appear in + `coordinator.log`, `doctor.json`, `bridge.py status`, coordinator acknowledgements or rejections, or + `program-scopes.json`, a rejected report logs fixed text only (never SidePulse's error string), and `doctor.json` + filters window diagnostics to allow-listed integer counters. 3. **Exact versions in documentation**: compatibility and behavior claims in `README.md` and [`docs/compatibility.md`](docs/compatibility.md) name the exact Tern, OMP, SidePulse, and macOS versions they were - exercised against, and never describe a local socket write as physical LED output. + exercised against, and never describe a local socket write or acknowledged report as physical LED output. ## Brand, media, and public site diff --git a/README.md b/README.md index 88202a3..facb3f8 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ **Your OMP sessions in Tern. On SidePulse.** -**Exercised on macOS 27.2 with Tern `0.9.12`, OMP `18.16.0`, and SidePulse revision `ffb1d3c2`.** +**Exercised on macOS 27.2.1 with Tern `0.9.16`, OMP `18.18.7`, and SidePulse revision `ad4a5217`.** -tern-sidepulse is a [Tern](https://stencil.so/tern) window plugin. It puts the [Oh My Pi](https://github.com/can1357/oh-my-pi) (OMP) sessions visible in your open Tern windows, including sessions on attached remote hosts, on [SidePulse](https://github.com/inteliwear/sidepulse): Tern supplies the window state, and SidePulse drives the LEDs and menu-bar status alongside your other monitored agents. The plugin never reads transcripts, submits prompts, approves actions, or changes window layouts. +tern-sidepulse is a [Tern](https://stencil.so/tern) window plugin. It puts the [Oh My Pi](https://github.com/can1357/oh-my-pi) (OMP) sessions visible in your open Tern windows, including sessions on attached remote hosts, on [SidePulse](https://github.com/inteliwear/sidepulse) — one SidePulse row per OMP session, named after its tab or pane: Tern supplies the window state, and SidePulse drives the LEDs and menu-bar status alongside your other monitored agents. The plugin never reads transcripts, submits prompts, approves actions, or changes window layouts. A stylized Tern window with two OMP panes beside SidePulse's eight-LED strip: one working pane shows the cyan roll; when the other pane asks a question SidePulse switches to waiting for input with a slow amber pulse; after both turns finish SidePulse shows completed in solid green, then the status clears to idle. @@ -30,11 +30,11 @@ tern-sidepulse is a [Tern](https://stencil.so/tern) window plugin. It puts the [ [releases]: https://github.com/alphastorm/tern-sidepulse/releases [release-badge]: https://img.shields.io/github/v/release/alphastorm/tern-sidepulse?filter=v*&label=release&color=70B3F7&labelColor=0B0E11 [compatibility]: docs/compatibility.md -[tern-badge]: https://img.shields.io/badge/Tern%20baseline-0.9.12-70B3F7?labelColor=0B0E11 +[tern-badge]: https://img.shields.io/badge/Tern%20baseline-0.9.16-70B3F7?labelColor=0B0E11 [license]: LICENSE [license-badge]: https://img.shields.io/github/license/alphastorm/tern-sidepulse?color=1C232B&labelColor=0B0E11 -Private by design: nothing listens on the network · six fields read per agent row · no transcripts, prompts, or working directories · tab and pane labels stay in coordinator memory · nothing installed on remote hosts +Private by design: nothing listens on the network · six fields read per agent row · no transcripts, prompts, or working directories · SidePulse reports carry salted scope hashes, never host keys or pane ids ("labels": false hides tab and pane titles too) · nothing installed on remote hosts Community project; not affiliated with or endorsed by the Oh My Pi, Tern, or SidePulse maintainers. @@ -42,20 +42,21 @@ tern-sidepulse is a [Tern](https://stencil.so/tern) window plugin. It puts the [ ## What you see -| OMP in a visible Tern window | SidePulse | +| OMP session in a visible Tern window | SidePulse row (`state` / mode) | | --- | --- | -| Any session working | `working` (your configured working animation) | -| Any session waiting for input (an `ask`, an approval) | `waiting_for_input`; outranks `working` | -| A turn finished | `completed` for 15 s, unless the session resumes first | -| A turn failed | `blocked_error` for 30 s, unless the session resumes first | -| Nothing visible, or all idle | `idle_ready` (clears this plugin's status) | +| Working | `working` (your configured working animation) | +| Waiting for input (an `ask`, an approval) | `blocked` / `waiting_for_input`; outranks `working` | +| A turn finished | `done` / `completed` for 15 s, unless the session resumes first | +| A turn failed | `error` / `blocked_error` for 30 s, unless the session resumes first | +| Open at the prompt | `idle` / `idle_ready` | +| Pane closed, host disconnected, plugin disabled, or last window closed | `clear` (removes the row within about 20 s) | -Closing a pane, losing a host connection, disabling the plugin, or closing the last window clears the status within about 20 s. Multiple Tern windows combine into one session on SidePulse: duplicates across windows are reduced, never counted. +Each OMP session (`(host, pane)`) appears as its own row in SidePulse's **Agents** list, named after its user-given tab name or OMP pane title (`OMP in Tern` when unlabelled or when `"labels": false` is set in `config.json`; when a label contains `": "`, SidePulse displays the text before `": "` as the project). Multiple Tern windows viewing the same session deduplicate into one row by highest-priority state and newest non-empty label, and at most 32 rows are sent (most urgent first). ## Requirements - macOS with Tern 0.9.12 or later (exercised versions are in [docs/compatibility.md](docs/compatibility.md)). -- SidePulse's agent monitor on the same Mac: the menu-bar app, the headless service, or both. +- SidePulse on the same Mac at a build that includes [inteliwear/sidepulse#72](https://github.com/inteliwear/sidepulse/pull/72) (merged 2026-11-10 as `ad4a5217`), installed or updated with `sidepulse update` on or after 2026-11-10 so the SidePulse service provides `program-status.sock`. For older SidePulse builds, use `tern-sidepulse` `0.1.0` (which reports one combined session). - Python 3.10 or later at a known absolute path: Homebrew's `/opt/homebrew/bin/python3` or `/usr/local/bin/python3`, a versioned `python3.10`–`python3.14` in either prefix, the python.org framework's `python3`, or `/usr/bin/python3` only when the Command Line Tools provide it. Nothing is installed with `pip`. - Remote hosts need nothing installed: no SidePulse, no helper, and no service. @@ -79,8 +80,8 @@ To pin a release, check out its tag and run `tern plugin install /path/to/checko ## Confirm it works 1. Wait about 5 s after installing or linking so the window registers and picks up any existing OMP sessions (nothing needs restarting). -2. Open the Tern command palette and run `tern-sidepulse: doctor`. Expect a toast starting with `ok:` (`ok: 0 issue(s); socket delivery is not an LED check`). A toast starting with `warn:` names a check that needs attention, such as one SidePulse receiver not running or no snapshot yet; `~/.local/state/tern-sidepulse/doctor.json` lists each check and its remedy. -3. Check SidePulse's menu-bar app (or `~/.local/state/sidepulse/agent-monitor/latest.json` when running headless): while an OMP session works or waits, one session from origin `Tern` (`OMP in Tern`) appears. +2. Open the Tern command palette and run `tern-sidepulse: doctor`. Expect a toast starting with `ok:` (`ok: 0 issue(s); an accepted report is not an LED check`). A toast starting with `warn:` or `error:` names a check that needs attention, such as `receiver` when SidePulse is stopped or predates `program-status.sock` (`sidepulse update`); `~/.local/state/tern-sidepulse/doctor.json` lists each check and its remedy. +3. Check SidePulse's **Agents** list in the menu-bar app (or run `sidepulse status` when running headless): each OMP session in your open Tern windows appears as its own row from origin `Tern`, labelled by its tab or pane title (`OMP in Tern` when unlabelled or when `"labels": false` is set). ## Commands @@ -88,9 +89,9 @@ From the Tern command palette: | Command | Does | | --- | --- | -| `tern-sidepulse: doctor` | Checks Python, the data and runtime directories, the coordinator, this window, and each SidePulse receiver; shows a one-line toast and writes `~/.local/state/tern-sidepulse/doctor.json` | -| `tern-sidepulse: resync` | Re-registers this window and resends the current state to SidePulse | -| `tern-sidepulse: disable` | Persists the `disabled` latch file, drops every registered window, and clears this plugin's status on SidePulse | +| `tern-sidepulse: doctor` | Checks Python, the data and runtime directories, the coordinator, this window, and the SidePulse `program-status.sock` receiver (`receiver` check); shows a one-line toast and writes `~/.local/state/tern-sidepulse/doctor.json` | +| `tern-sidepulse: resync` | Re-registers this window and resends every current row to SidePulse | +| `tern-sidepulse: disable` | Persists the `disabled` latch file, drops every registered window, and clears every row this plugin has shown on SidePulse | | `tern-sidepulse: enable` | Removes the `disabled` latch file; this window registers right away and other open windows on their next 5 s cycle | The same operations, plus `status`, from a shell in the plugin directory with Python 3.10 or later: @@ -102,21 +103,25 @@ python3 bridge.py disable --data-dir "$HOME/Library/Application Support/Tern/pl python3 bridge.py enable --data-dir "$HOME/Library/Application Support/Tern/plugin-data/tern-sidepulse" ``` -Every CLI command prints one JSON object to stdout. A successful socket write to SidePulse confirms local delivery, not physical LED output. +Every CLI command prints one JSON object to stdout. An acknowledged report to SidePulse confirms local acceptance, not physical LED output. ## Configuration -To override Python discovery or SidePulse socket paths, create `config.json` in `$HOME/Library/Application Support/Tern/plugin-data/tern-sidepulse` (must be a regular file of at most 64 KiB, not a symlink; anything else is ignored): +To override Python discovery, SidePulse socket paths, or label delivery, create `config.json` in `$HOME/Library/Application Support/Tern/plugin-data/tern-sidepulse` (must be a regular file of at most 64 KiB, not a symlink; anything else is ignored): ```json { "python": "/opt/homebrew/bin/python3.13", - "ui_sockets": ["/custom/path/events.sock"], - "service_sockets": ["/custom/path/relay-events.sock"] + "program_sockets": ["/custom/path/program-status.sock"], + "labels": false } ``` -`python` sets the absolute path to a Python 3.10+ interpreter; reload the plugin (`tern plugin reload tern-sidepulse`) after changing it. `ui_sockets` and `service_sockets` override SidePulse's default socket candidates in `$XDG_STATE_HOME/sidepulse/agent-monitor` and `~/.local/state/sidepulse/agent-monitor` (including SidePulse's `/tmp/sidepulse-relay--.sock` fallback when the `relay-events.sock` path exceeds 96 bytes) the next time the coordinator starts. +- `python` sets the absolute path to a Python 3.10+ interpreter; reload the plugin (`tern plugin reload tern-sidepulse`) after changing it. +- `program_sockets` overrides SidePulse's default `program-status.sock` candidates in `$XDG_STATE_HOME/sidepulse/agent-monitor` and `~/.local/state/sidepulse/agent-monitor` (including SidePulse's `/tmp/sidepulse-status-/.sock` fallback when the socket path exceeds 96 bytes). For CLI and test launches, `TERN_SIDEPULSE_PROGRAM_SOCKETS` (`:`-separated) and `bridge.py coordinator --program-socket PATH` (repeatable) take precedence over `program_sockets`. +- `labels` defaults to `true`. Setting `"labels": false` stops sending tab and pane titles to SidePulse; every row then sends `"title": ""` and `"display_name": "OMP in Tern"`. + +`program_sockets` and `labels` are read when the coordinator starts. A running coordinator keeps its startup setting until it exits: run `tern-sidepulse: disable` and then `tern-sidepulse: enable` to restart it on the next window snapshot. ## How it works @@ -124,27 +129,28 @@ To override Python discovery or SidePulse socket paths, create `config.json` in flowchart LR W1["Tern window 1
window.luau"] -- register / snapshot --> C["coordinator
(one per user)"] W2["Tern window 2
window.luau"] -- register / snapshot --> C - C -- Interrupt / UserPromptSubmit / … --> U["SidePulse app
events.sock"] - C -- Interrupt / UserPromptSubmit / … --> S["SidePulse service
relay-events.sock"] + C -- program_status reports --> S["SidePulse service
program-status.sock"] ``` - Each Tern window runs an *observer* (the per-window `window.luau` instance) that checks `cx.agents:list()` every 5 s and on `agent_state`, `agent_finished`, `pane_closed`, `session_ended`, and `budget` events (coalesced over 75 ms). It keeps OMP panes on connected hosts whose live surface role is `omp.session` and sends a complete snapshot (host key, pane id, state, any 15 s completion or 30 s failure notice, and an optional tab or pane label) through `bridge.py` to the local coordinator socket. -- The first helper call spawns one background coordinator per user that holds a singleton lock, keeps one row per OMP session keyed by `(host, pane)` and deduplicated across windows, reduces those rows in priority order (`blocked_error`, `waiting_for_input`, `working`, `completed`, `idle_ready`) to one combined status (`OMP in Tern`), and delivers the result to both SidePulse receivers (the menu-bar app on `events.sock` and the headless service on `relay-events.sock`) with bounded retry. Labels stay in the coordinator's memory only and are not sent to SidePulse. Each window holds a 15 s *lease* (an expiry timer renewed by every complete snapshot); a closed window stops contributing when its lease expires, and the coordinator sends a final clear event and exits 5 s after the last lease ends (or after at most 60 s if SidePulse is unreachable). -- The plugin data directory (`$HOME/Library/Application Support/Tern/plugin-data/tern-sidepulse`) holds `identity.json` (which sets the synthetic SidePulse session id `tern-sidepulse:`), optional `config.json`, the `disabled` latch file, and `pycache/` for Python bytecode. Live observations stay in memory only so a restart never replays a stale prompt, and the SidePulse wire contract is documented in [docs/compatibility.md](docs/compatibility.md). +- The first helper call spawns one background coordinator per user that holds a singleton lock, keeps one row per OMP session keyed by `(host, pane)` and deduplicated across windows in priority order (`blocked_error`, `waiting_for_input`, `working`, `completed`, `idle_ready`) with the newest non-empty label, and sends one `program_status` report per row (at most 32 rows, most urgent first) to SidePulse's `program-status.sock` receiver. Each row is addressed by a salted scope (`tern-sidepulse-<24 hex>`) and named by its tab or pane title (`OMP in Tern` when unlabelled or when `"labels": false` is set). Only changed rows are sent, active rows (`working`, `blocked`, `error`) are refreshed every 300 s, and withdrawn rows send `"state": "clear"`. Each window holds a 15 s *lease* (an expiry timer renewed by every complete snapshot); a closed window stops contributing when its lease expires, and the coordinator clears every shown scope and exits 5 s after the last lease ends (or after at most 60 s if SidePulse is unreachable). +- The plugin data directory (`$HOME/Library/Application Support/Tern/plugin-data/tern-sidepulse`) holds `identity.json` (whose `install_id` salts every scope hash), optional `config.json`, the `disabled` latch file, and `pycache/` for Python bytecode. The runtime directory (`~/.local/state/tern-sidepulse`) holds a write-ahead scope ledger (`program-scopes.json`, salted scope hashes only) written before a scope's first report and pruned when its clear is acknowledged; if a coordinator crashes, the next coordinator keeps those inherited scopes for one 15 s lease so still-open panes are overwritten in place and closed panes are cleared when the lease ends. Live observations stay in memory only, and the SidePulse wire contract is documented in [docs/compatibility.md](docs/compatibility.md). ## Privacy and hardening -The plugin reads `pane`, `state`, `kind`, `program`, `host`, and `alive` from each `cx.agents:list()` row; `id`, `state`, `panes`, `kind`, `address`, and `name` from `cx.hosts:list()`; and the `surface.role` of each pane. When a window has at least one OMP pane, it also calls `cx.session:panes()` and `cx.session:tabs()` at most once per 5 s pass to read `pane`, `tab`, and `title` from each pane and `id` and `name` from each tab. Each OMP pane is labelled with its user-given tab name (`TabInfo.name`) when non-blank, else the OMP pane's own `PaneInfo.title` (never `TabInfo.title`, which is whichever pane is focused in a split tab), cut to 256 bytes at a UTF-8 boundary in the window and sanitized in the coordinator (whitespace collapsed, control characters, lone surrogates, and private-use characters such as OMP's status glyph removed, trimmed, and capped at 96 characters). Labels and host keys (`local`, or a remote host's `address`, else `name`, else `id:`) travel only from the window to the helper's stdin to the coordinator's memory: they never appear in `coordinator.log`, `doctor.json`, `bridge.py status` output, coordinator acknowledgements, or the SidePulse socket payload (`status` and `doctor` report row counts — `rows` by mode, `rows_total`, `rows_labelled` — and allow-listed integer window diagnostic counters in `doctor.json`, including `label_tab`, `label_title`, `label_none`, `labels_unavailable`, `labels_dropped`, `host_fallback`, and `encode_failed`; `tests/test_privacy.py` and `tests/test_rows.py` pin this). The plugin never reads working directories, model names, commands, prompts, assistant text, tool arguments, or transcript paths. Report a vulnerability privately through [SECURITY.md](SECURITY.md). +The plugin reads `pane`, `state`, `kind`, `program`, `host`, and `alive` from each `cx.agents:list()` row; `id`, `state`, `panes`, `kind`, `address`, and `name` from `cx.hosts:list()`; and the `surface.role` of each pane. When a window has at least one OMP pane, it also calls `cx.session:panes()` and `cx.session:tabs()` at most once per 5 s pass to read `pane`, `tab`, and `title` from each pane and `id` and `name` from each tab. Each OMP pane is labelled with its user-given tab name (`TabInfo.name`) when non-blank, else the OMP pane's own `PaneInfo.title` (never `TabInfo.title`, which is whichever pane is focused in a split tab), cut to 256 bytes at a UTF-8 boundary in the window and sanitized in the coordinator (whitespace collapsed, control characters, lone surrogates, and private-use characters such as OMP's status glyph removed, trimmed, and capped at 96 characters). The plugin never reads working directories (`cwd`), model names, commands, prompts, assistant text, tool arguments, or transcript paths. + +By default, sanitized labels are sent to SidePulse in each row's `program_status` report (`context.title`), and if you have configured a SidePulse relay or phone link, SidePulse forwards each row's latest update with `status.title` (cut to 192 bytes), `provider`, and `session_id` the same way it forwards Claude and Codex titles; with no relay or phone link configured, nothing leaves the Mac, and setting `"labels": false` in `config.json` stops sending labels to SidePulse altogether. Host keys (`local`, or a remote host's `address`, else `name`, else `id:`) never appear outside coordinator memory, and pane ids and host keys never leave the Mac: SidePulse scopes (`tern-sidepulse-<24 hex>`), `session_id`, and `program-scopes.json` hold only salted `sha256(install_id NUL host NUL pane)[:24]` hashes (local `status` and `doctor.json` list pane ids of active outcome notices). Labels and host keys never appear in `coordinator.log`, `doctor.json`, `bridge.py status` output, coordinator acknowledgements, or `program-scopes.json`, and a rejected report logs fixed text only, never SidePulse's error string (`status` and `doctor` report row counts — `rows` by mode, `rows_total`, `rows_labelled` — and allow-listed integer window diagnostic counters in `doctor.json`, including `label_tab`, `label_title`, `label_none`, `labels_unavailable`, `labels_dropped`, `host_fallback`, and `encode_failed`; `tests/test_privacy.py` and `tests/test_rows.py` pin this). Report a vulnerability privately through [SECURITY.md](SECURITY.md). -- **Private local files and sockets**: Nothing listens on the network. `~/.local/state/tern-sidepulse` (mode `0700`, ownership checked, symlinks refused) holds `coordinator.sock`, `coordinator.lock`, `coordinator.log`, and `doctor.json`; those files, `identity.json`, and `disabled` are written with mode `0600` under `umask 077`, and `coordinator.sock` is published by atomic rename after `listen(16)`. -- **Bounded requests and state**: Coordinator requests must be strict UTF-8 JSON (no `NaN`/`Infinity`, deep nesting rejected), capped at 1 MiB, EOF-framed within a 2 s read deadline, and answered within a 0.5 s write deadline across at most 32 concurrent connections; the window keeps each encoded snapshot under 192 KiB by dropping labels and retrying once (`labels_dropped`). State is capped at 64 windows, 512 panes per window, and 256 registration tokens, with printable window keys of at most 64 characters, host keys of at most 128 bytes in the window and 128 characters in the coordinator, and labels of at most 96 characters after sanitizing (a malformed label is dropped without rejecting the snapshot). +- **Private local files and sockets**: Nothing listens on the network. `~/.local/state/tern-sidepulse` (mode `0700`, ownership checked, symlinks refused) holds `coordinator.sock`, `coordinator.lock`, `coordinator.log`, `doctor.json`, and `program-scopes.json`; those files, `identity.json`, and `disabled` are written with mode `0600` under `umask 077`, and `coordinator.sock` is published by atomic rename after `listen(16)`. +- **Bounded requests and state**: Coordinator requests must be strict UTF-8 JSON (no `NaN`/`Infinity`, deep nesting rejected), capped at 1 MiB, EOF-framed within a 2 s read deadline, and answered within a 0.5 s write deadline across at most 32 concurrent connections; the window keeps each encoded snapshot under 192 KiB by dropping labels and retrying once (`labels_dropped`). State is capped at 64 windows, 512 panes per window, 256 registration tokens, and 32 delivered SidePulse rows, with printable window keys of at most 64 characters, host keys of at most 128 bytes in the window and 128 characters in the coordinator, and labels of at most 96 characters after sanitizing (a malformed label is dropped without rejecting the snapshot). - **Isolated helper execution**: Helpers run as argument vectors (never through a shell) with `python3 -I -S -X pycache_prefix=/pycache` and a 4 s timeout; running `python3 bridge.py …` from a shell sets `sys.dont_write_bytecode = True` so no `__pycache__` is written into the plugin directory. Failed helper calls back off at `500 * 2^n` ms (capped at 30 s), and interpreters below Python 3.10 (exit status 3, `python_too_old`) are skipped for the life of the window. ## Diagnostics -- `~/.local/state/tern-sidepulse/coordinator.log` (rotated to `coordinator.log.1` at 1 MiB) records status changes, deliveries, expiries, 5 s clock jumps, and errors, never payloads. When `$HOME` is so deep that the socket path plus its 11-byte bind suffix would exceed 100 bytes, the runtime directory falls back to `$TMPDIR/tern-sidepulse` and then `/tmp/tern-sidepulse--`; `doctor` prints the active path. -- `~/.local/state/tern-sidepulse/doctor.json` holds the full JSON report from the last `doctor` run. -- `~/.local/state/sidepulse/agent-monitor/status-history.jsonl` and `latest.json` show SidePulse's own read-only view of ingested events and current status. +- `~/.local/state/tern-sidepulse/coordinator.log` (rotated to `coordinator.log.1` at 1 MiB) records lease expiries, enable/disable, delivery failures and recoveries, rejected reports, scopes inherited from a crashed coordinator, 5 s clock jumps, and errors, never payloads, labels, or host keys. When `$HOME` is so deep that the socket path plus its 11-byte bind suffix would exceed 100 bytes, the runtime directory falls back to `$TMPDIR/tern-sidepulse` and then `/tmp/tern-sidepulse--`; `doctor` prints the active path. +- `~/.local/state/tern-sidepulse/doctor.json` holds the full JSON report from the last `doctor` run, and `program-scopes.json` lists the salted scope hashes currently registered with SidePulse. +- `sidepulse status` (or `sidepulse live`) shows SidePulse's own view of the current rows. - Tern's log (`tern::plugin` target) emits one `warn`-level line when helper calls start failing (`tern-sidepulse helper failing`) and one when they recover (`tern-sidepulse helper recovered`). - Linked-checkout reloads: Tern watches a linked plugin directory and reloads on every file change inside it, including `.git/`. If `core.fsmonitor` is enabled globally, run `git config --local core.fsmonitor false` in the checkout so Git commands do not reload the plugin. @@ -158,8 +164,10 @@ The plugin reads `pane`, `state`, `kind`, `program`, `host`, and `alive` from ea ## Known limitations - **Brief turns**: Tern samples agent state, so a turn that fails or completes within about 1 s may not emit an in-progress sample; the 15 s completion or 30 s failure notice still appears. -- **Single combined session**: One synthetic SidePulse session (`tern-sidepulse:`) represents all open Tern windows; distinct OMP panes are not counted separately. -- **Unclean coordinator stop or long outage**: Clearing the status after the last window closes requires the coordinator to stay alive and reach SidePulse within its 60 s final grace period. A hard-killed coordinator (`SIGKILL`) or a longer SidePulse outage leaves the last status until the next coordinator start clears that session id. +- **Crashed coordinator with no later window**: SidePulse keeps `program_status` rows in memory and no longer ages out non-`done` rows ([inteliwear/sidepulse#72 comment](https://github.com/inteliwear/sidepulse/pull/72#issuecomment-6676920089)). If a coordinator crashes (`SIGKILL`) and no Tern window ever starts another coordinator, its rows stay in SidePulse until SidePulse restarts or another coordinator starts and clears the scopes recorded in `program-scopes.json`. +- **32-row cap**: SidePulse shares a 64-row table across all providers and evicts the least recently updated row, so `tern-sidepulse` sends at most 32 rows, ordered by urgency (`blocked_error`, `waiting_for_input`, `working`, `completed`, `idle_ready`). +- **Done rows after a SidePulse restart**: When SidePulse restarts, the coordinator resubmits every current row except `completed` (`done`) rows so an older turn does not read as a fresh completion; those rows go out again when their state changes. +- **Label refresh interval**: Labels are read on the 5 s reconciliation pass (without a title-event subscription), so tab and pane renames take up to 5 s to appear on SidePulse. - **Remote hosts follow open windows**: Remote OMP sessions are observed through the Tern window connected to that host; nothing polls a remote host after all windows close. - **Startup and surface role changes**: A pane counts while Tern reports its surface role as `omp.session` (which includes wrapped commands such as `env … omp`). The role is re-read every 5 s, so an OMP session still starting is picked up on the next 5 s pass, and a pane that exits OMP drops out within 5 s. @@ -170,7 +178,7 @@ python3 -B -m unittest discover -s tests -t . -v # -B keeps bytecode out of a luau-lsp analyze --definitions=types/tern.d.luau window.luau ``` -`types/tern.d.luau` is the `tern plugin types` output from Tern 0.9.12; regenerate it when targeting a newer Tern release. When the `luau` CLI is on `PATH` (or `LUAU=/path/to/luau` is set; `TERN_SIDEPULSE_REQUIRE_LUAU=1` fails instead of skipping), `tests/test_luau_harness.py` runs `window.luau` headlessly against the test drives in `tests/luau/`. Set `SIDEPULSE_PYTHON` to a SidePulse interpreter (defaults to `~/.local/share/sidepulse/venv/bin/python` when present) to run `tests/test_sidepulse_contract.py` against the real SidePulse normalizer, and set `TERN_SIDEPULSE_SLOW_TESTS=1` to include the 20 s default-limits timing test in `tests/test_e2e.py`. +`types/tern.d.luau` is the `tern plugin types` output from Tern 0.9.12; regenerate it when targeting a newer Tern release. When the `luau` CLI is on `PATH` (or `LUAU=/path/to/luau` is set; `TERN_SIDEPULSE_REQUIRE_LUAU=1` fails instead of skipping), `tests/test_luau_harness.py` runs `window.luau` headlessly against the test drives in `tests/luau/`. Set `SIDEPULSE_SRC=/src` (with `TERN_SIDEPULSE_REQUIRE_CONTRACT=1` to fail instead of skipping) to run `tests/test_sidepulse_contract.py` against SidePulse's `program_status` implementation, and set `TERN_SIDEPULSE_SLOW_TESTS=1` to include the 20 s default-limits timing test in `tests/test_e2e.py`. Artwork and demo media are rendered by `python3 scripts/render_assets.py` (requires headless Chrome, `ffmpeg` with `libx264`, and network access for the webfonts; `--check` compares the committed PNGs on the same machine; render from a checkout that is not `tern plugin link`ed, because Tern reloads the plugin on every file write). [docs/BRAND.md](docs/BRAND.md) is the brand spec, and `tests/test_site.py` keeps `README.md`, `plugin.toml`, `window.luau`, `site/`, and `.github/workflows/pages.yml` coherent. diff --git a/SECURITY.md b/SECURITY.md index 68b76e5..606d0da 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -24,11 +24,17 @@ The threat model and hardening controls are documented in `cx.session:surface(pane, {nodes = 1, depth = 1})`; and, at most once per 5 s pass when the window has at least one OMP pane, `pane`, `tab`, and `title` from `cx.session:panes()` plus `id` and `name` from `cx.session:tabs()`. Labels come only from user-given tab names (`TabInfo.name`) and OMP panes' own `PaneInfo.title` (never `TabInfo.title`), and - the plugin never reads working directories, model names, commands, prompts, assistant text, tool arguments, or - transcript paths. Labels and host keys travel only from the window to the `bridge.py` helper's stdin to the local - coordinator's memory: they never appear in `coordinator.log`, `doctor.json`, `bridge.py status` output, coordinator - acknowledgements, or the SidePulse socket payload, whose `"prompt"` key is always the constant string `"OMP in Tern"` - (`tests/test_privacy.py` and `tests/test_rows.py` pin this). + the plugin never reads working directories (`cwd`), model names, commands, prompts, assistant text, tool arguments, or + transcript paths. By default, sanitized labels are sent to SidePulse in each row's `program_status` report + (`context.title`), and only if the user configured a SidePulse relay or phone link does SidePulse forward them (the + same way it forwards Claude and Codex titles); setting `"labels": false` in `config.json` stops sending labels to + SidePulse (`"title": ""` and `"display_name": "OMP in Tern"`). Host keys never appear outside coordinator memory, and + pane ids and host keys never leave the Mac: SidePulse scopes (`tern-sidepulse-<24 hex>`), `context.session_id`, and + the write-ahead scope ledger (`program-scopes.json`) hold only salted `sha256(install_id NUL host NUL pane)[:24]` + hashes (local `status` and `doctor.json` list pane ids of active outcome notices). Labels and host keys never appear + in `coordinator.log`, `doctor.json`, `bridge.py status` output, coordinator acknowledgements, or + `program-scopes.json`, and a rejected report logs fixed text only, never SidePulse's error string + (`tests/test_privacy.py`, `tests/test_rows.py`, and `tests/test_transport.py` pin this). - **Coordinator socket protocol**: `~/.local/state/tern-sidepulse/coordinator.sock` (and its fallback runtime paths), strict UTF-8 JSON validation (`NaN`/`Infinity` and deep nesting rejected), the 1 MiB request cap (with the window's 192 KiB snapshot budget that drops labels to fit), read/write deadlines (2 s / 0.5 s), connection (32), state (64 @@ -39,11 +45,11 @@ The threat model and hardening controls are documented in `python3 -I -S -X pycache_prefix=/pycache` with a 4 s timeout. - **Local file and directory modes**: `~/.local/state/tern-sidepulse` created and verified with mode `0700` (ownership checked, symlinks refused), and `coordinator.sock`, `coordinator.lock`, `coordinator.log`, `doctor.json`, - `identity.json`, and `disabled` written with mode `0600` under `umask 077` (`coordinator.sock` published by atomic - rename after `listen(16)`). + `program-scopes.json`, `identity.json`, and `disabled` written with mode `0600` under `umask 077` (`coordinator.sock` + published by atomic rename after `listen(16)`). - **`config.json` handling**: `$HOME/Library/Application Support/Tern/plugin-data/tern-sidepulse/config.json` accepted only when it is a regular file of at most 64 KiB (symlinks and special files refused), and validated before launching - a configured Python interpreter or overriding socket paths. + a configured Python interpreter, overriding `program_sockets`, or applying the `labels` setting. ### Out of scope diff --git a/docs/compatibility.md b/docs/compatibility.md index a1a1742..a893bc3 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -1,17 +1,17 @@ # Compatibility and contract probe -Versions exercised on the development laptop (November 5, 2026): +Versions exercised on the development laptop: | Component | Version | Notes | | --- | --- | --- | -| macOS | 27.2 (26B123) | Apple Silicon | -| Tern | 0.9.12 (e498b49), `/Applications/Tern.app` | Dock-launched; plugin processes inherit `PATH=/usr/bin:/bin:/usr/sbin:/sbin` | +| macOS | 27.2.1 (26B131) | Apple Silicon; the 0.1.0 checks ran on 27.2 (26B123) | +| Tern | 0.9.16 (41a10a5), `/Applications/Tern.app` | 0.2.0 checks (November 10, 2026); the 0.1.0 checks ran on 0.9.12 (e498b49). Dock-launched; plugin processes inherit `PATH=/usr/bin:/bin:/usr/sbin:/sbin` | | Tern SDK declarations | `tern plugin types` output from 0.9.12, pinned as `types/tern.d.luau` | Research baseline was stencil-hq/tern-sdk `a3ba62fd` (November 4, 2026) | -| OMP | 18.16.0 | Shell-typed `omp` and `tern new tab -- omp` blocks | -| SidePulse | 0.2.4.dev6+gffb1d3c2f (venv at `~/.local/share/sidepulse`) | Exactly the inspected revision `ffb1d3c2` | +| OMP | 18.18.7 | Shell-typed `omp` and `tern new tab -- omp` blocks; the 0.1.0 checks used 18.16.0 | +| SidePulse | 0.2.4.dev36+gad4a5217f (venv at `~/.local/share/sidepulse`) | The [inteliwear/sidepulse#72](https://github.com/inteliwear/sidepulse/pull/72) merge `ad4a5217` (2026-11-10; SidePulse desktop has no release tags, `setup.sh` and `sidepulse update` install `main`) | | Python | 3.15.2 (`/opt/homebrew/bin/python3`), 3.13.18 also present | `/usr/bin/python3` is 3.9.6 and is never chosen | | Luau tooling | luau 0.745 (`luau`, `luau-analyze`), luau-lsp 1.70.1 (`luau-lsp analyze --definitions=types/tern.d.luau`) | Development/CI checks (`tests/test_luau_harness.py` and static analysis) | -| Remote host | A Mac Studio attached over Tern remoting, Tern 0.9.12 there too | No SidePulse, helper, or service on the remote host | +| Remote host | A Mac Studio attached over Tern remoting, Tern 0.9.12 there too (0.1.0 checks) | No SidePulse, helper, or service on the remote host | `plugin.toml` has no minimum-API field. At load, `window.luau` probes `cx.agents:list`, `cx.hosts:list`, `cx.session:surface`, and `tern.process.run` under `pcall`; when any member is missing, the window stays inert and reports the missing member through the `tern-sidepulse: doctor` toast and `doctor.json`. `tern.timer` runs in the entry chunk itself, so a Tern build without `tern.timer` fails to load the plugin outright. @@ -76,53 +76,77 @@ How the window and coordinator handle labels and host keys (and the integer diag - **Host key**: `local` for the local host, or a remote host's `address` when non-empty, free of control characters, and at most 128 bytes, else its `name`, else `id:` (incrementing `host_fallback`). - **Sanitize rule (`tern_sidepulse/reducer.py`)**: The coordinator collapses whitespace runs to one space, removes C0 controls (`U+0000`–`U+001F`), `DEL` and C1 controls (`U+007F`–`U+009F`), lone surrogates (`U+D800`–`U+DFFF`), and Unicode private-use characters (`U+E000`–`U+F8FF`, `U+F0000`–`U+FFFFD`, `U+100000`–`U+10FFFD`, including OMP's status glyph), trims leading and trailing spaces, and caps the result at 96 characters (an empty string becomes `None`). A malformed wire label is dropped without rejecting the snapshot. - **Size chain**: `window.luau` cuts each label to at most 256 bytes at a UTF-8 character boundary (`MAX_LABEL_BYTES = 256`) and caps host keys at 128 bytes (`MAX_HOST_KEY_BYTES = 128`) across at most 512 observations per window. If the encoded snapshot exceeds 192 KiB (`MAX_SNAPSHOT_BYTES = 192 * 1024`) or `tern.json.encode` fails while labels are present, the window strips all labels, increments `labels_dropped`, and re-encodes once so status delivery still succeeds (a persistent encode failure increments `encode_failed` and backs off). The coordinator caps requests at 1 MiB (`max_request_bytes = 1024 * 1024`), host keys at 128 characters, and sanitized labels at 96 characters. -- **Privacy and SidePulse boundary**: Labels and host keys travel only from the window to the helper's stdin to the coordinator's memory. They never appear in `coordinator.log`, `doctor.json`, `bridge.py status` output, coordinator acknowledgements, or the SidePulse socket payload (`status` and `doctor` report `rows` by mode, `rows_total`, `rows_labelled`, and the allow-listed window diagnostic counters `label_tab`, `label_title`, `label_none`, `labels_unavailable`, `labels_dropped`, `host_fallback`, and `encode_failed` only). SidePulse still receives one synthetic session (`tern-sidepulse:`), origin `Tern`, constant `"OMP in Tern"` title, and one combined mode; per-session rows in SidePulse require [SidePulse PR #72](https://github.com/inteliwear/sidepulse/pull/72)'s `program_status` protocol, so the `tern-sidepulse` program-status adapter and the `tern-sidepulse` 0.2.0 release are held until `inteliwear/sidepulse#72` merges and ships in a SidePulse release. +- **Privacy and SidePulse boundary**: Labels and host keys travel over the helper's stdin pipe to the coordinator's memory. By default, sanitized labels are sent to SidePulse in each row's `program_status` report (`context.title`); setting `"labels": false` in `/config.json` sends `"title": ""` and `"display_name": "OMP in Tern"` in `context` instead. Host keys never appear outside coordinator memory (beyond that stdin pipe), and pane ids and host keys never leave the Mac: SidePulse scopes (`tern-sidepulse-<24 hex>`), `context.session_id` (`<24 hex>`), and the on-disk scope ledger (`/program-scopes.json`) store only `sha256(install_id NUL host NUL pane)[:24]` hashes salted with `install_id` from `identity.json` (local `status` and `doctor.json` list pane ids of active outcome notices). Labels and host keys never appear in `coordinator.log`, `doctor.json`, `bridge.py status` output, coordinator acknowledgements, or `program-scopes.json` (`status` and `doctor` report `rows` by mode, `rows_total`, `rows_labelled`, and allow-listed integer window diagnostic counters including `label_tab`, `label_title`, `label_none`, `labels_unavailable`, `labels_dropped`, `host_fallback`, and `encode_failed`). + +## SidePulse program-status contract (verified at `ad4a5217`, inteliwear/sidepulse#72) + +`tern-sidepulse` 0.2.0 talks only to SidePulse's program-status protocol ([inteliwear/sidepulse#72](https://github.com/inteliwear/sidepulse/pull/72), merged 2026-11-10 as `ad4a5217`); the 0.1.0 hook-event transport (`events.sock` and `relay-events.sock`) is removed. + +- **Receiver and socket paths**: The SidePulse background service (`io.sidepulse.service`) listens on `program-status.sock` in SidePulse's state directory (`$XDG_STATE_HOME/sidepulse/agent-monitor`, else `~/.local/state/sidepulse/agent-monitor`), or `/tmp/sidepulse-status-/.sock` when that path exceeds 96 bytes (`sidepulse_program_socket_for_dir` mirrors upstream `status_socket_path`). Candidates can be overridden with `program_sockets` in `config.json`, `TERN_SIDEPULSE_PROGRAM_SOCKETS`, or `bridge.py coordinator --program-socket PATH`. After `#72`, `events.sock` still exists in the state directory but only answers `{"command": "open-settings"}` (other JSON is ignored, so 0.1.0 writes succeed and do nothing), and `relay-events.sock` is gone. When `relay-events.sock` exists without `program-status.sock`, `tern-sidepulse: doctor` fails the `receiver` check (`this SidePulse predates program status`, remedy `sidepulse update`); `tern-sidepulse` 0.1.0 remains the version for pre-`#72` SidePulse builds. +- **Wire framing and acknowledgements**: One UTF-8 JSON object per `AF_UNIX` `SOCK_STREAM` connection within a 0.2 s send timeout (`SEND_TIMEOUT_SECONDS = 0.2`), framed by half-closing the write side (`shutdown(SHUT_WR)`). The daemon replies with one JSON object (up to 64 KiB): `{"ok": true, "seq": n, "revision": n}` when accepted, or `{"ok": false, "error": "…"}` (`"Daemon is busy…"` triggers retry backoff; any other rejection marks the entry rejected without retrying until the row changes or SidePulse restarts, increments `status.transport.rejected`, raises the `receiver_rejections` doctor warning, and logs fixed text only, never SidePulse's error string). +- **Report shapes**: + - Labelled row (`labels` enabled and row has a non-empty sanitized label; `display_name` is omitted): + `{"v":1,"type":"program_status","scope":"tern-sidepulse-<24 hex>","request_id":"","status":{"state":"working"},"context":{"provider":"omp","origin":"Tern","session_id":"<24 hex>","title_source":"session","title":"