Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 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
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
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