The core model
Five nouns, used the same way by every source. The scheduler already implemented most of them for the clock; the Triggers work generalises them.
Event types and subjects
Event types are dotted and source-prefixed: schedule.fired, webhook.received (or webhook.<X-Scion-Event>), github.pull_request.opened. Every source also fills a subject, a stable key for “the thing this event is about”:
| Source | Subject |
|---|---|
| webhook | webhook:<endpoint-id>[/<X-Scion-Subject>] |
| github | github:owner/repo#N (push: github:owner/repo@ref) |
| schedule | schedule:<id> |
| chat (Stage 4) | chat:<conversation> |
A rule can override the subject with its own expression (for example an order id from the payload). The subject policy on the trigger then decides what a second event for the same subject does. The policy is source-agnostic: the drainer never looks at the source kind (decision D5).
| Mode | Meaning | When |
|---|---|---|
new | Every matching event fires. | Stage 1 |
skip | If a live fire for this (trigger, subject) exists, record skipped "subject busy". | Stage 1 PR 4; Stage 2 adds a subject-claims table |
reuse | If the subject already has a running agent from this trigger, deliver the event to it as a message (with wake) instead of dispatching another. | Stage 3 (G4), over Stage 2’s claims |
Stage 3 also adds coalesce_window (latest event wins, maximum 10 minutes; presets use 30 s to fold synchronize bursts).
The durable inbox
Ingress verifies, stores the event and enqueues a work item in the same transaction, then answers 202. Agreed decision D3 required the queue to be a reusable, hub-wide primitive rather than a trigger table, so it lives in pkg/durablequeue with no trigger types in it:
- Leased rows (lease owner, lease expiry, attempts, next attempt), claimed in bounded batches by a drainer on every hub replica; SQLite uses the same code with one drainer.
- Items carry a kind (
trigger.eventtoday), a dedup key unique per kind, a project id for fair trimming, and an opaque payload. - Lifted from the agent-lifecycle outbox pattern. Named future consumers: message delivery (follow-up ptone/scion#8034) and possibly the lifecycle outbox itself.
- The trigger handler records every fire before it completes the item; an hourly reaper fails fires stuck in
firingafter a restart and reconciles pending events that lost their queue item.
Where the fire core and authority checks sit
firecore_*.go, action_*.go) stays in package hub; new trigger code lives in pkg/hub/trigger and the shared types in pkg/hub/hubfire (decision D-S1-1).Authority is the scheduler’s model, inherited rather than reinvented: at authoring the hub records the creator’s principal, credential and an authorization_revision, and freezes an effect ceiling. Any edit that changes a future fire bumps the revision. At every fire the hub re-resolves that authority, checks the ceiling, re-runs the live permission check for the action on its target, and checks standing. If the creator is deleted the trigger pauses (creator_deleted); a deleted message target pauses it with target_deleted; a deleted endpoint with source_deleted. No trigger can do more than its creator could do interactively at fire time.
Curated source kinds vs user-created endpoints and rules
A source kind is Go code chosen by Scion; the set is closed (Stage 1 accepts only webhook on the trigger API). Users create instances, a webhook endpoint or a schedule, and triggers that point at them. GitHub has no per-user instance: the hub’s single App is the source, scoped to a project by the existing installation association. This was settled by ptone on 2026-11-16 when the question arose whether to keep the raw trigger API public: Trigger CRUD stays public; defining a new source kind is not an API.