Events

session.milestone is the short list a webhook relays. A turn starts and finishes. A commit, a push, and a pull-request state come from finished tool output. ask_user_question is WaitingOnPermission. A sandbox or policy refusal is Refused and names the path or the command. A finished histos, sbt, test, or compile command is CommandFinished, with the exit code and one line of its result. Any non-zero exit is CommandFailed, so a failed build is both. An ordinary tool call is not a milestone. A notice never carries file contents.

Progress fires while a turn is still running, at most once per terret.command.progress (default 5 minutes), and only after that window had tool calls. The text names those calls, for example reading NOTES.md, ran ./histos test. A command shows its program and its subcommand. A later window does not repeat an earlier call. When output has not changed for terret.command.stall (default 10 minutes), and no terminal command is running, the milestone kind is Stalled, once, until output moves again.

session.activity is the finer stream. Each fact has a stable id, a parent (the turn id turn:<epoch> or the tool call id), a kind, and the journal time. A tool update on that stream is the new output, not the whole output again. The journal keeps the cumulative frame. Each journal entry also records the turn epoch and the time it was appended.

follow is a subscription, not a job. A host listens with MCP subscriptions/listen, or opens GET /sessions/{session}/events as server-sent events. The SSE id is the journal index. after and Last-Event-ID continue strictly after that index, and Last-Event-ID wins when both are set. Closing the stream does not cancel the turn.

export returns that same log. Optional after is exclusive and is applied first. milestones keeps only milestone events. latest keeps the newest N of that selection. cursor is the tail of the whole log, even when latest returns a shorter window, and state is the session state. One call shows whether the caller is caught up.

terret.journal.limit (TERRET_JOURNAL_LIMIT) is how many events one session log keeps. The default is 4096. Past that, the oldest entries drop and the indexes that remain do not move. Zero or a negative limit is rejected.

terret.events.verification is Skip or Required and defaults to Skip. terret.events.floor, terret.events.default, and terret.events.cap bound a webhook's TTL and default to 1 minute, 2 hours, and 24 hours. A requested ttl below the floor is raised, an omitted ttl uses the default, and a longer one, including an unbounded ttl, is the cap. The event subscriber's principal is key: plus the first 8 hex characters of the SHA-256 of the configured key.

Tokens, secret-shaped keys, and email addresses are replaced with [redacted] before an event leaves the process.

Milestones.classify(Event.Stalled("turn output has not changed for 10 minutes", Instant.EPOCH))
Chunk(Notice(Stalled,turn output has not changed for 10 minutes,stalled:0))
Milestones.classify(Event.Progress("reading NOTES.md, ran ./histos test", Instant.EPOCH))
Chunk(Notice(Progress,reading NOTES.md, ran ./histos test,progress:0))
terret.config.CommandBudget.default
CommandBudget(PT15M,PT10M,PT5M)
terret.app.ProcessConfig.local.events
EventPolicy(Skip,PT1M,PT2H,PT24H)