Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body:
id: privacy
attributes:
label: Privacy and security impact
description: Confirm how the change preserves the six-field agent read boundary, local-only sockets, and standard-library-only runtime.
description: Confirm how the change preserves the six-field agent read boundary (`pane`, `state`, `kind`, `program`, `host`, `alive`), in-memory-only OMP tab and pane labels, local-only sockets, and standard-library-only runtime (see `README.md#privacy-and-hardening`).
validations:
required: true
- type: textarea
Expand All @@ -33,7 +33,7 @@ body:
attributes:
label: Scope checks
options:
- label: This keeps the plugin within its read-only status boundary (never reading transcripts, prompts, or pane titles, and never mutating Tern windows).
- label: This keeps the plugin within its read-only status boundary (never reading transcripts, prompts, working directories, or model names, keeping OMP tab and pane labels in coordinator memory only, and never mutating Tern windows).
required: true
- label: I understand that the runtime and tests use the Python 3.10+ standard library only.
required: true
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
- [ ] `luau-lsp analyze --definitions=types/tern.d.luau window.luau` passes
- [ ] Documentation facts name the exact Tern, Oh My Pi (OMP), SidePulse, and macOS versions exercised, and never describe a socket write as LED output
- [ ] `python3 scripts/render_assets.py --check` passes when `assets/`, `docs/media/`, or `docs/BRAND.md` changed
- [ ] Privacy invariants in `tests/test_privacy.py` are untouched (only the six agent fields, four host fields, and `surface.role` are read; no transcripts, prompts, titles, or private paths appear in this PR)
- [ ] Privacy invariants in `tests/test_privacy.py` are untouched (only the six agent fields, the six host fields, `surface.role`, and OMP tab names or pane titles are read; labels and host keys never leave coordinator memory; and this PR description and diff contain no real user transcripts, prompts, pane titles, or private paths)
- [ ] `CHANGELOG.md` is updated for user-visible changes
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Fetch luau-lsp 1.70.1
run: |
curl -sSL -o luau-lsp.zip https://github.com/JohnnyMorganz/luau-lsp/releases/download/1.70.1/luau-lsp-linux-x86_64.zip
unzip -q luau-lsp.zip
chmod +x luau-lsp
- name: Fetch Luau 0.745
run: |
mkdir -p luau-bin
curl -fsSL -o luau.zip https://github.com/luau-lang/luau/releases/download/0.745/luau-ubuntu.zip
unzip -q luau.zip -d luau-bin
chmod +x luau-bin/luau
- run: ./luau-lsp analyze --definitions=types/tern.d.luau window.luau
- run: python -m unittest tests.test_luau_harness -v
env:
LUAU: ${{ github.workspace }}/luau-bin/luau
TERN_SIDEPULSE_REQUIRE_LUAU: "1"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 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:<n>`) 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).
- 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.

## 0.1.0 — 2026-11-05

First release.
Expand Down
31 changes: 20 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ behavior claims are backed by evidence, privacy boundaries stay intact, and the
- **Python 3.10 or later**: the runtime (`bridge.py`, `tern_sidepulse/`) and test suite (`tests/`) use the Python
standard library only (compatible with Python 3.10+, so do not import `tomllib`). Nothing is installed with `pip`,
and the repository uses no Node or Bun dependencies.
- **`luau-lsp` 1.70.1**: analyzes `window.luau` against `types/tern.d.luau` (the `tern plugin types` output from Tern
0.9.12; release archives are published at
[JohnnyMorganz/luau-lsp v1.70.1](https://github.com/JohnnyMorganz/luau-lsp/releases/tag/1.70.1), as in
[`.github/workflows/ci.yml`](.github/workflows/ci.yml)).
- **`luau-lsp` 1.70.1 and `luau` 0.745**: `luau-lsp` analyzes `window.luau` against `types/tern.d.luau` (the
`tern plugin types` output from Tern 0.9.12; release archives at
[JohnnyMorganz/luau-lsp v1.70.1](https://github.com/JohnnyMorganz/luau-lsp/releases/tag/1.70.1)), and `luau` runs
`window.luau` headlessly in `tests/test_luau_harness.py` (release archives at
[luau-lang/luau 0.745](https://github.com/luau-lang/luau/releases/tag/0.745), as in
[`.github/workflows/ci.yml`](.github/workflows/ci.yml); set `LUAU=/path/to/luau` when not on `PATH`, or
`TERN_SIDEPULSE_REQUIRE_LUAU=1` to fail instead of skipping when `luau` is absent).
- **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.
Expand Down Expand Up @@ -52,13 +55,19 @@ 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`)**: the window observer (`window.luau`) reads only `pane`, `state`,
`kind`, `program`, `host`, and `alive` from `cx.agents:list()`, `id`, `state`, `panes`, and `kind` from
`cx.hosts:list()`, and `surface.role` from `cx.session:surface(pane, {nodes = 1, depth = 1})`. It never reads pane
titles, working directories, model names, prompts, assistant text, tool arguments, or transcript paths.
`tests/test_privacy.py` pins that extra client fields never leave the coordinator, `doctor.json` filters window
diagnostics to known integer counters, and the SidePulse socket payload carries only the eight fixed protocol keys
(where `"prompt"` is always the constant label `"OMP in Tern"`, never user prompt text).
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).
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.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tern-sidepulse is a [Tern](https://stencil.so/tern) window plugin. It puts the [
[license]: LICENSE
[license-badge]: https://img.shields.io/github/license/alphastorm/tern-sidepulse?color=1C232B&labelColor=0B0E11

<sub><strong>Private by design:</strong> nothing listens on the network · six fields read per agent row · no transcripts, prompts, or titles · nothing installed on remote hosts</sub>
<sub><strong>Private by design:</strong> 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</sub>

<sub>Community project; not affiliated with or endorsed by the Oh My Pi, Tern, or SidePulse maintainers.</sub>

Expand Down Expand Up @@ -128,16 +128,16 @@ flowchart LR
C -- Interrupt / UserPromptSubmit / … --> S["SidePulse service<br/>relay-events.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 (pane id, state, and any 15 s completion or 30 s failure notice) through `bridge.py` to the local coordinator socket.
- The first helper call spawns one background coordinator per user that holds a singleton lock, combines all windows' snapshots in priority order (failed, waiting, working, finished, idle), 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. 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).
- 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:<install_id>`), 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).

## Privacy and hardening

The plugin reads only `pane`, `state`, `kind`, `program`, `host`, and `alive` from each `cx.agents:list()` row, `id`, `state`, `panes`, and `kind` from `cx.hosts:list()`, and the `surface.role` of each pane. It never reads pane titles, working directories, model names, prompts, assistant text, tool arguments, or transcript paths. None of those fields appear in the helper protocol, the coordinator log, `doctor.json`, or the SidePulse socket payload (`tests/test_privacy.py` pins this). 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). Labels and host keys (`local`, or a remote host's `address`, else `name`, else `id:<n>`) 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).

- **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 256 KiB, EOF-framed within a 2 s read deadline, and answered within a 0.5 s write deadline across at most 32 concurrent connections. State is capped at 64 windows, 512 panes per window, and 256 registration tokens, with printable window keys of at most 64 characters.
- **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).
- **Isolated helper execution**: Helpers run as argument vectors (never through a shell) with `python3 -I -S -X pycache_prefix=<data>/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
Expand Down Expand Up @@ -170,7 +170,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. 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_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`.

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.

Expand Down
Loading
Loading