Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ee21c60
events: a session says which of the person's rules started it
kombuchapunk Nov 25, 2026
bdbe38e
control: the notice a receiver sends for a trigger, on the wire
kombuchapunk Nov 25, 2026
c772874
proto: the trigger rule and its file, defined once in config.proto
kombuchapunk Nov 25, 2026
d81725d
spec: triggers, in CONTROL.md §14, with the scenarios an engine runs
kombuchapunk Nov 25, 2026
35053aa
triggers: what a person confirms is what runs, and a level is never w…
kombuchapunk Nov 25, 2026
93a614f
spec: triggers count a run when it is taken, and say what they cannot…
kombuchapunk Nov 25, 2026
89e55a2
triggers: an unknown level gives no run, the folder's floor is higher…
kombuchapunk Nov 25, 2026
0ba926e
spec: the edits-run note points at the recorded step-0 fixture
kombuchapunk Nov 25, 2026
b16d9be
triggers: one run of a rule at a time, a cut line keeps its mark, and…
kombuchapunk Nov 25, 2026
e427e1a
triggers: a path segment loses its trailing dots and spaces by a loop…
kombuchapunk Nov 25, 2026
8e78d53
triggers: list and test answers get schemas, and the scenarios say a …
kombuchapunk Nov 25, 2026
15aff9d
triggers: the sentence is cut to the width, a hidden character's hint…
kombuchapunk Nov 25, 2026
3352afa
triggers: a continued session's folder has its scenario, and a pause …
kombuchapunk Nov 25, 2026
4828d43
triggers: trigger line prints the add command that makes a rule again
kombuchapunk Nov 25, 2026
7b4e529
triggers: a hint by why a character was refused, columns as a termina…
kombuchapunk Nov 25, 2026
4218208
triggers: dropped waits, the trigger line and the session's folder ha…
kombuchapunk Nov 25, 2026
c488b97
triggers: close round 4 definition findings in spec, proto, model, an…
kombuchapunk Nov 25, 2026
e1efcca
control: the trigger rules file, written by the CLI only, and its guard
kombuchapunk Nov 25, 2026
a435931
control: the trigger engine, run through the ask path
kombuchapunk Nov 25, 2026
0a026ca
cli: triggers on|off|status and trigger add|list|pause|resume|remove|…
kombuchapunk Nov 25, 2026
1d2ce14
cli: doctor and status say whether triggers are on, and how many rules
kombuchapunk Nov 25, 2026
8deecca
core: the trigger schemas from the main entry
kombuchapunk Nov 25, 2026
24bcdaf
control: no turn runs with another cause's tools, and nothing in the …
kombuchapunk Nov 25, 2026
b8cc592
cli: a continue rule takes its session's folder, and nothing is writt…
kombuchapunk Nov 25, 2026
374e7c4
control: a hand-made record runs nothing extra, and nothing a depende…
kombuchapunk Nov 25, 2026
ea1ae8b
cli: trigger line prints the add command that makes a rule again, and…
kombuchapunk Nov 25, 2026
1f05991
control: a queued run is checked when it would begin, one daemon runs…
kombuchapunk Nov 25, 2026
89e1323
cli: trigger line is raw, zsh-safe and add's own, and the rules' lock…
kombuchapunk Nov 25, 2026
5fe7c9a
triggers: close round 4 local findings (claim reuse, day clamp, --jso…
kombuchapunk Nov 25, 2026
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
18 changes: 18 additions & 0 deletions .changeset/trigger-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"sessionpipe": minor
"sessionpipe-core": patch
---

`sessionpipe triggers` and `sessionpipe trigger`: your rules, made at this computer's terminal

- `sessionpipe triggers on | off | status`: triggers are off until you turn them on. `on` shows every rule in plain words, with the level each really runs at on this computer, and takes a typed `yes`; it installs the background service if none runs. `off` stops every rule at once.
- `sessionpipe trigger add <name>` makes a rule on a receiver's notices (`--on board.example --topic acme/tasks`) or on a clock (`--every "mon 09:00"`, `day 08:30`, `2h`). It checks what a run would (the folder is allowed, the agent runs here, the receiver is paired, the session to continue is here), says when a receiver does not send notices or the words name a field the rule doesn't require, shows the rule and the level it will run at here (and why when that is narrower than asked), and takes a typed `yes`. No flag skips it.
- `trigger list` shows each rule in a line, its runs today against its cap, and what it did (ran, refused and why, missed, couldn't start); `trigger test` shows what a sample notice or a tick would run, running nothing; `pause`, `resume` and `remove`. `--json` on `list`, `status` and `test` prints the messages config.proto defines.
- Every command that changes a rule refuses inside a coding session. Characters that don't show are written out wherever a rule is shown.
- A rule that continues a session takes that session's folder: `add` shows it on the folder line and refuses another `--folder`.
- When the rules change in another terminal while you read a rule before typing `yes`, nothing is written: "The rules changed while you were reading. Nothing was written. Run the command again."
- `sessionpipe trigger line <name>` prints the one `sessionpipe trigger add …` command that makes the rule again, exactly as it is at a terminal of any width or in a pipe (`| pbcopy` takes it whole), to make the same rule on another computer: the flags in one fixed order, a value quoted for sh, bash and zsh only when it must be, and a value that starts with `-` written `--flag=<value>`, which `trigger add` now takes for every option. It runs `add`'s checks, so a rule `add` would refuse here is refused with why. `--json` prints it with its words.
- Two commands never write the rules over each other: a command that changes them takes a lock, and another command meanwhile says "Another sessionpipe command is changing the rules. Run it again." A lock left by a command that ended is let go of at once.
- `trigger list` says a run dropped because its rule was paused or changed; `--json` says why a rules file can't be read. A terminal too narrow to show a rule whole asks nothing and says to widen it.
- `sessionpipe ask off` and `sessionpipe control off` keep the background service while triggers are on.
- `sessionpipe-core` exports the machine's own files' schemas (`CONFIG_SCHEMAS`).
5 changes: 5 additions & 0 deletions .changeset/trigger-doctor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sessionpipe": patch
---

`sessionpipe doctor` and `status` say whether your trigger rules are on and how many there are (and how many are paused), once there is a rules file; a rules file that can't be read is a thing to fix. With triggers on, the background service is something this computer needs, and its absence is said.
16 changes: 16 additions & 0 deletions .changeset/trigger-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"sessionpipe": minor
---

The background service runs the person's trigger rules

- A rule on a clock (`mon 09:00`, `day 08:30`, `2h`) runs at its time in this computer's local time, once, however many of its ticks the computer slept through, when the latest is under six hours late; later it is refused `missed`. The nights the clocks change are handled: a skipped time runs as the clock jumps past it, a repeated one runs once.
- A run goes the way a local `sessionpipe ask` goes, at the rule's level narrowed by this computer's mode (and, continuing a session, by that session's own level), with the rule's MCP tools allowed, its framed words and `SESSIONPIPE_TRIGGERED_BY` in the session's environment. It answers no permission prompt.
- Each rule runs at most its cap a day. A run waits while this computer's caps on new sessions are reached, or while a window holds the session it continues (never a copy, never handed to the window), and is refused when it waits too long. A rule whose session is gone is paused by this computer, in its own record; the rules file stays as the person confirmed it.
- Turning triggers off drops every run that waits, a run waiting behind another turn in its session's line too, and stops every triggered run in progress. A run stopped before it began gives its count back.
- A rule that continues a session runs only in that session's own folder, and only when that is the rule's folder, allowed and not a place a rule may never run. A turn of a rule never goes into a session something else holds, and nothing else's turn goes into a session a rule opened: such a session is closed when the rule's turn ends.
- A run waiting behind another turn in its session's line, or for a free turn, outlives a restart, as every waiting run does, and the stopping service does nothing more. A run handed over is checked again the moment its turn would begin: its rule there and the same, its folder and level as they are now. A rule paused, removed or changed drops the runs taken for it that have not begun, their notices told the rule took nothing, and `trigger list` says so.
- With the Agent SDK, `triggers off` and a run's deadline stop a start that waits for a free turn, as they do with `claude -p`.
- One service runs the rules: a second one started at the same moment runs none of them, and never writes their record.
- The service's record of the rules is read as untrusted, and runs a rule no more than its cap allows, only for ticks its clock had and notices the rule takes, counted on each one's own day whatever the record says; a notice is told at most one outcome, and only one this computer received. A tick that can't be recorded waits for the next look: whatever does not fit is left out and said in its log, and nothing in it, or in the rules file, can stop the service starting. A rule may be named anything the rules allow, `constructor` too.
- Everything a rule did is kept for `sessionpipe trigger list`: the latest lines, a week at most.
10 changes: 10 additions & 0 deletions .changeset/trigger-notices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"sessionpipe": minor
"sessionpipe-core": minor
---

The notice a receiver sends for a trigger, defined

- The protocol defines a notice (`control-notice.json`): a receiver's unsigned word that something changed on a topic the machine listed, as a closed set of short typed fields with no session, words, folder, level or tool. It travels in a new `notices` list beside `messages` in a poll answer, at most 50 at a time, and is acked at `POST {control}/notices/ack` (`control-notice-ack.json`) with its outcome alone: what ran is never said.
- A machine's hello can carry `triggers`: whether triggers are on and the topics a receiver may send notices on. A receiver's well-known file can say `control.notices`.
- `sessionpipe-core` exports `parseNotice`, `noticesIn` and `noticeAck`, which read a notice against the generated definition and build its ack. Nothing runs on a notice yet.
10 changes: 10 additions & 0 deletions .changeset/trigger-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"sessionpipe": minor
"sessionpipe-core": minor
---

A trigger rule, defined once

- A rule and the rules file (`<config>/triggers.json`) are defined in `proto/sessionpipe/v1/config.proto`, with what `sessionpipe trigger list --json`, `trigger test --json` and `trigger line --json` will print. The file is the machine's own: its schema, and those of what `trigger list --json` and `trigger test --json` print, are generated for the CLI and the background service and published nowhere.
- `sessionpipe-core` exports pure functions over them: `checkTriggers` and `readTriggers` (a file that does not fit is refused whole; a rule's words and folder may hold no character that does not show, and its folder must clear a floor: not the home folder or above it, not sessionpipe's or a harness's own folders, not a dot-folder in home, not `~/Library`; `triggerPlaces` and `realFolderProblem` check it on real paths), `describeRule` (what a person confirms: a sentence about the rule, cut to the terminal's width at spaces, then the folder and the words on their own marked lines, cut to the terminal's width with every piece marked, with anything that does not show as itself written out by `visible`, and a refusal of such a character that says what to do by its kind: a pasted space, an emoji's joiner or selector, stacked marks), `helloTriggers` (the topics a receiver learns, and nothing else), `matchNotice` and `firstMatch`, `triggerLevel` (never wider than the rule, `edits` for a rule a notice runs, the machine's mode, the session's own level or what the harness takes), `ruleWords` and `composeWords` (the person's words, the notice's tokens in backticks, framed), `triggerRun`, `sampleNotice`, `testAnswer`, and `triggerLine` with `shellWord` (the one `trigger add` command that makes a rule again, in a fixed order and POSIX quoting, `conformance/triggers/trigger-line.json`).
- A rule's subject pattern is a small, safe subset of regular expressions (`^X-[0-9]{1,6}$`): anchored, no groups or alternation, matched without backtracking, so a subject chosen by someone else can never make a match slow.
10 changes: 10 additions & 0 deletions .changeset/triggered-by.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"sessionpipe": minor
"sessionpipe-core": minor
---

A session can say which of your rules started it

- A session's events may carry `triggered_by`: the name of the rule (`sessionpipe trigger`, coming next) that the background service started or resumed it for. The hook reads it from `SESSIONPIPE_TRIGGERED_BY`, as it reads `SESSIONPIPE_LAUNCHED_BY`, and ignores a value that is not a rule's name. It names, and allows nothing.
- Everything that starts a further session resets the variable with the other lineage variables, so a session started from a triggered one is not marked as the rule's.
- `sessionpipe-core` exports `triggeredBy`, `TRIGGERED_BY_ENV` and `RULE_NAME_RE`, the one pattern a rule is named by.
55 changes: 55 additions & 0 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,61 @@
poll's messages arriving together, the running one finishing, one being refused. Run by
`packages/cli/test/control-line.test.ts`; a second implementation of the machine runs the
same file.
- `triggers/*.json` — the person's trigger rules, the notices a receiver sends, their acks, the
hello's topics and the clock (spec/CONTROL.md §14). A scenario file is `{ spec, note, cases }`;
a case is `{ name, machine, triggers, steps }` and what the machine knew before it:
- `machine`: `{ mode, folders, harnesses, receivers, places, levels? }`, the machine's mode
(`safe`, `auto`, `inherit`), its allowed folders, the harnesses it runs headlessly, the
receivers it is paired with (by host), `places` (`{ home, config, state, harnesses, system, platform }`,
what a rule's folder is checked against: CONTROL.md §14.1, *The folder's floor*) and, where a
case needs it, `levels` (per harness, the levels it takes here, as a hello's
`start.<harness>.permissions`; absent, the harness takes every level. A case with Codex gives
`levels.codex`, `[read, safe, auto]`: Codex has no `edits`);
- `triggers`: `<config>/triggers.json` exactly (`null`: no file). `triggers_ok: false` marks a
file the machine must refuse whole, and so read as triggers off;
- optional: `sessions` (`{ "<harness>:<id>": { level, held, folder } }`, the sessions a rule
continues, their recorded level, whether a window holds one, and the folder the session runs
in, which a run of a rule continuing it uses (one with no `folder` is a session whose folder
the machine can't tell: refused `folder`); a session not listed is gone), `seen`
(notice ids already seen, `{ receiver, id, at }`), `today` (the rules' runs earlier that local
day, `{ rule, subject, state, at, result }`), `starts` (`{ running, last_hour, headless? }`, the
starts counted against the machine's caps: in progress, and in the sliding hour, the latter
made at the first step's instant; and the headless turns no trigger made in the machine's
slots), `limits` (`{ start_concurrent?, headless? }`, 2 and 3 when absent), `last_tick` (per clock rule; a rule with none was first seen when it first appeared, or at its resume or new `every`, and an interval's first tick is one interval after it), `zone` (the machine's time
zone, for the day and the clock).
Each step has an `at` and at most one of: `poll` (`{ receiver, body }`, a poll answer that
receiver gave), `hello` (the receiver a hello goes to now), `change` (the rules file as the
person changed it at the machine), `tick` (a clock rule's time came), `wake` with `asleep` (the
machine slept from `asleep` and woke at `at`), `release` (a window let go of that session),
`sessions` (sessions as they are now: each named one replaced, or `null` when gone),
`start_ended` (that many starts no trigger made ended), `headless_ended` (that many headless
turns no trigger made ended), `run_ended` (the indexes of triggered runs that ended), `machine` (the machine's settings as the person changed them at its terminal,
the fields given), `resume` (the person ran `trigger resume` for that rule), `permission` (a
triggered run raised a prompt); a step with none is time passing to `at`. Within a step, waiting
runs whose deadline passed (a deadline is exclusive) are settled first, refused for what they
waited for (`busy`, `held`, `start_limit`), then every waiting run that may begin does, in the
order taken, then what the step does, then again every waiting run that may begin. A `hello`
goes only to a receiver in `machine.receivers`. Its `expect` holds what must follow: `acks`
(`{ id, outcome, code?, session? }`, the machine's clock aside; `"<harness>:*"` is a session the
run made), `runs` (`{ rule, run, env }`, `run` being `config.proto`'s `TriggerRun` and `env` what
the run's environment gains), `triggers` (a hello's), `hello: true` (a hello goes out at once),
`history` (`{ rule, result, code?, subject?, state? }`, lines a rule's history gains, every
run and refusal of a rule that took the cause, a notice's with its subject and state; `result`
is `ran`, `refused`, `failed`, `missed` or `dropped`, in the order written within one rule), and `unacked` (ids past the fiftieth), `cancelled` (the
indexes, in the case's order, of the triggered runs a `triggers off` cancels), `paused` (rules
the machine paused), `message_acks` (the poll's messages, which the command path acks) and
`answered_by_machine` where a case says them. An absent list means none, and `hello` absent
means no hello goes out at once. Acks are compared by `id`: their order within a step is not
part of the protocol. `rules-file.json` (`{ places, cases: [{ name, file, ok, places? }] }`, a
case's own `places` where it has one) and `subject-patterns.json` (`{ pattern, ok,
matches?, misses? }`) are the reader's alone, and `trigger-line.json` (`{ cases: [{ name,
rule, line, argv }] }`) is `trigger line`'s, run by `packages/core/test/trigger-line.test.ts`. Run by `packages/core/test/trigger-fixtures.test.ts`
against the definition's functions and a small model of CONTROL.md §14.7, which checks every
expectation of every step; the daemon's tests run the same files against the daemon. Only a
daemon can show: a clock in a time zone other than UTC (every case here is `UTC`), a waiting
run that outlives a restart, real paths against the allowlist, the levels a harness's binary
takes, a hello and an ack actually sent and retried, and that a permission prompt is left to
the harness (`answered_by_machine: false`).
- `control-vectors/*.json` — signed control commands, valid and broken, and enrollment
proofs, each with the verdict every verifier must reach (spec/CONTROL.md §5). Run by
`packages/core/test/control-vectors.test.ts`; `npm run vectors` writes the ones not yet
Expand Down
31 changes: 31 additions & 0 deletions conformance/control-vectors/171-kind-trigger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "kind-trigger",
"description": "A trigger.add, signed correctly by a trusted passkey's day key: no command makes a rule, so the kind is unknown.",
"input": {
"signed": {
"cmd": "{\"v\":1,\"t\":\"sessionpipe.control\",\"machine\":\"m_testmachine0000000001\",\"kind\":\"trigger.add\",\"session\":\"sessionpipe:triggers\",\"text\":\"Card {subject} is yours and in TODO.\",\"nonce\":\"DLvrnbrfXfVtyBF18u4EEA\",\"iat\":1790800000000}",
"csig": "EHtgkfkENDDRUOkuWWPjcRicxl3NytA_rFtUStsD3JfD7J679AXPT4XlWgbb5qRm66NGRKYWfwvXoHLbadABsw",
"grant": {
"cred": "AFn-sf-e4slqib1a76sSbbC2lOdPQkN5",
"ad": "tq21o0mX3Y6Rfy9222k5JGexApF1SebHaw_vL_v20iMFAAAABw",
"cd": "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiemlETnV4TnlZdDZEbUVQYWNZYk01WUdRWUhqeTh6MDM0YkZrbE5HZWdOOCIsIm9yaWdpbiI6Imh0dHBzOi8vcmVjZWl2ZXIuZXhhbXBsZSIsImNyb3NzT3JpZ2luIjpmYWxzZX0",
"sig": "MEQCIBudq1nMmblrZ-XLSeXXQJ9KqKlo6lxazJPHaWpeVd_pAiA1fw3_BrOSS9luEu2kuDaC_cqycmr5riQW8FRaYvjFlQ",
"str": "{\"v\":1,\"t\":\"sessionpipe.grant\",\"pub\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEZgSxO88V3nS-YxAuPg6OjzyotKq7JYW8WqCBHb7DXaebXP2kX-lhhtA2LkZ3WASipcRnb6JZd2Cer5oZTo30jg\",\"iat\":1790799940000,\"exp\":1790843140000,\"rp\":\"receiver.example\"}"
}
},
"machine": "m_testmachine0000000001",
"rp_id": "receiver.example",
"trusted": [
{
"id": "AFn-sf-e4slqib1a76sSbbC2lOdPQkN5",
"alg": -7,
"spki": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQWJglHXQiKSV933uGl7nTTJxGV8lyfRP_BLcR6KrnFs-m14hrIfED76ZNpdaYkrvK5nZKMgp17CVVlQqqpdfmQ"
}
],
"now": 1790800060000
},
"expect": {
"ok": false,
"code": "unknown_kind"
}
}
42 changes: 42 additions & 0 deletions conformance/harness/claude-code/session-start-triggered-by.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"harness": "claude-code",
"event": "SessionStart",
"recorded": {
"at": "2026-10-21T17:06:35.578Z",
"harness_version": "2.1.300",
"how": "The hook payload recorded for session-start-launched-by.json (claude -p --settings <hooks>, this branch's hook as the SessionStart entry, from a scratch folder with SESSIONPIPE_STATE at a scratch state and SESSIONPIPE_NO_WORKER=1; the prompt asked for one word; paths scrubbed), byte for byte, with SESSIONPIPE_TRIGGERED_BY in place of SESSIONPIPE_LAUNCHED_BY, as the control daemon sets it on a run it starts for a rule (CONTROL.md §14). The variable is sessionpipe's own and Claude Code passes it to its hooks unread, so the payload is the harness's as recorded."
},
"input": {
"argv": [
"claude-code",
"SessionStart"
],
"stdin": "{\"session_id\":\"c397e1dd-7a72-432b-b075-2e8dbe531037\",\"transcript_path\":\"/Users/user/.claude/projects/-Users-user-sessionpipe-record-ws/c397e1dd-7a72-432b-b075-2e8dbe531037.jsonl\",\"cwd\":\"/Users/user/sessionpipe/record/ws\",\"hook_event_name\":\"SessionStart\",\"source\":\"startup\"}\n",
"env": {
"CLAUDE_PROJECT_DIR": "/Users/user/sessionpipe/record/ws",
"SESSIONPIPE_TRIGGERED_BY": "card-todo"
},
"cwd": "/Users/user/sessionpipe/record/ws"
},
"expect": [
{
"id": "*",
"time": "*",
"tier": "*",
"type": "session.started",
"harness": {
"name": "claude-code",
"event": "SessionStart"
},
"session": {
"id": "c397e1dd-7a72-432b-b075-2e8dbe531037",
"cwd": "/Users/user/sessionpipe/record/ws",
"seq": "*",
"triggered_by": "card-todo"
},
"data": {
"source": "startup"
}
}
]
}
Loading
Loading