Pipelines and packs
Since 0.7.0 Tevrin runs on a reusable pipeline engine. The engine owns the state machine, the job queue, approval gates, the artifact store, the LLM layer and the run log. A pipeline definition (a YAML file) says what the stages are. A pack supplies the named C# pieces the definition refers to. The software lifecycle is the first pack, sdlc, and users see the same product.
Engine and pack
| Part | Project | Holds |
|---|---|---|
| Engine domain | Tevrin.Engine.Domain |
Definition model, validator, hash, state machine, cascade. Pure: no EF Core, ASP.NET Core or Npgsql |
| Engine runtime | Tevrin.Engine.Runtime |
YAML loader, registry, job queue, LLM providers, artifact store, gates, notifications, run log, agent stage runner |
| Engine API | Tevrin.Engine.Api |
The generic endpoints (reads, gate decisions, run control, triggers, feedback, outcomes) and the SignalR events |
| SDLC pack | Tevrin.Pack.Sdlc |
sdlc.pipeline.yaml, key constants, guard names, SdlcPack |
| Coach pack | Tevrin.Pack.Coach |
impulse-coach.pipeline.yaml, schemas, prompts, the Velocity guard, CoachPack (0.8.0) |
| Careers pack | Tevrin.Pack.Careers |
job-application.pipeline.yaml, job-digest.pipeline.yaml, schemas, prompts, its guards and handlers, CareersPack (0.9.0) |
| Studio pack | Tevrin.Pack.Studio |
content-studio.pipeline.yaml, schemas, prompts, its guards and render handler, StudioPack (0.9.0) |
| Forecasting pack | Tevrin.Pack.Forecasting |
forecast.pipeline.yaml, forecast-calibration.pipeline.yaml, schemas, prompts, its guards and handlers, the IPredictionMarketSource interface the host implements, ForecastingPack (0.9.0) |
| Markets pack | Tevrin.Pack.Markets |
market-research.pipeline.yaml, schemas, prompts, its guards and handlers, the IPriceHistorySource interface the host implements, MarketsPack (0.9.0) |
| Host | Tevrin.Api, Tevrin.Domain, Tevrin.Infrastructure |
Composes the pack: guard implementations, settings, start selector, project permissions, and read-only market data adapters (Polymarket, Alpaca) |
| Engine UI | frontend/src/engine/ |
Pipeline views that render any definition |
The dependency rule: no Tevrin.Engine.* assembly references the host projects (Tevrin.Api, Domain, Infrastructure) or Tevrin.Pack.*, and a pack references only the engine. An architecture test in Tevrin.Engine.Tests fails the build if that changes. A second test fails if an engine source file contains an SDLC key. A pack may not reference another pack or a host assembly either. The frontend has the same rule: an ESLint rule stops src/engine/ importing src/features/ or src/app/.
A definition
The SDLC lifecycle is sdlc.pipeline.yaml. A small example that runs in the engine tests is fixture-review.pipeline.yaml. It runs draft, check, gate, summarise: an agent drafts, a second agent checks the draft (a guard validates the report, with retry and feedback), a gate approves the report, and a third agent summarises.
pipeline: fixture-review
version: 1
title: Fixture review
trigger: { kind: manual }
start: [draft]
artifacts:
draft: { title: Draft, format: json, schema: draft.schema.json, approval: auto_lock }
stages:
- id: check
title: Check
status: checking
agent: { key: checker, prompt: fixture.check }
inputs: [draft]
output: report
validate: [{ guard: fixture.report-consistent }]
on_invalid: { retry_with_feedback: true, max_attempts: 3, then: escalate }
(Shortened. The full file declares every artifact, status and stage.)
Top-level keys
| Key | Meaning |
|---|---|
pipeline |
Id, kebab-case, unique across packs |
version |
Integer |
title |
Display title |
trigger |
{ kind: manual \| schedule \| webhook, input?, on_active? } (below) |
triggers |
A list of triggers, instead of trigger (below) |
approval_modes |
Modes the pipeline offers: strict, advisory, autonomous |
default_approval_mode |
The mode a new run uses |
start |
Stage ids a run can start in. The first is the default. A pack’s start selector may pick another |
settings |
Names of per-project values the pack supplies, such as review_cycles |
artifacts |
The artifacts, by key (below) |
statuses |
The pack’s own statuses, each mapped to a generic run status |
status_changes |
Named status-only moves (below) |
rollback_status |
Status a rollback sets. Without it, the target stage’s status is used |
concurrency |
exclusive: [{ job_type, scope: project }]: a second active job of that type in the same project is refused. scope: run is refused (DEF_PARSE, D-0.7.0-37). Since 0.8.0 also runs: one \| many (below) |
limits |
{ revisions, then }: a cap on backward transitions in a run (below) |
followups |
Stages that run after the run completes (below) |
outcomes |
Metrics a person records after the run, scored against a stage’s output (0.9.0, below) |
stages |
The stages, in order |
Artifacts
| Key | Meaning |
|---|---|
title |
Display title |
format |
markdown (default) or json |
schema |
Optional JSON Schema file the pack embeds. Agent output is checked against it before it is stored |
approval |
required (default: a person approves) or auto_lock |
cascade |
downstream (default), self_and_downstream or none: what approving a new version invalidates |
input |
true marks an artifact a person or trigger supplies (0.8.0, below) |
scope |
run (default) or project: a source-of-truth artifact shared by the project’s runs (0.8.0, below) |
Dependencies come from stage inputs. Artifact A depends on B when the stage that outputs A lists B as an input, directly or through other artifacts.
Statuses and status changes
statuses maps each custom status to a generic one: active, running, waiting_on_gate, completed, failed or cancelled. completed, failed and cancelled are final. A stage’s own status: is the status while the run is in it.
A status_changes entry moves a run’s status without changing stage.
| Key | Meaning |
|---|---|
stage |
The stage it applies to |
from |
Statuses it may start from |
to |
The new status |
completes_run |
Ends the run when true |
error_code |
The code returned when the current status isn’t in from |
error_message |
Optional text for that error. Placeholders: {stage}, {status}, {change_stage}, {from} |
reason |
Optional default reason recorded for the move. Defaults to the name in words |
wrong_stage_message |
Optional. A request naming another stage is refused with WRONG_PHASE and this text. Without it the named stage is ignored |
Stages
A stage is an agent stage (agent), a code stage (handler) or a manual stage (neither: the work happens through pack endpoints, as SDLC execution and release do). A stage can’t have both agent and handler.
| Key | Meaning |
|---|---|
id, title, status |
Identity, display title and the pack status while in the stage |
agent |
{ key, prompt?, model?, tools?, job_type? }. prompt defaults to the pack’s prompt for the key. job_type defaults to agent.run |
handler |
<pack>.<name>, an IStageHandler |
inputs |
Artifact keys the stage reads |
output |
The artifact key the stage writes |
requires |
Checks before entering, evaluated in order, all unmet reasons returned together. Entries: { artifact_locked: key }, { no_pending_gates: { except: [gate] } }, { guard: pack.name }, { input: key } (0.8.0) |
validate |
Guards run on the stage’s output, as { guard: pack.name }. Since 0.8.0 also { agent: key }, a validator agent |
on_invalid |
{ retry_with_feedback, max_attempts (1-10), then: escalate or fail } |
gate |
{ type, modes, approves?, approval_links?, description? }. The gate must be approved to enter the stage in the listed modes. description (0.9.0, at most 500 characters, not blank) is the copy the gate inbox and the run’s gate list show the reviewer, so a pack words its gates without frontend code. It’s left out of the definition hash when unset, so adding the key to the engine changed no existing hash |
on_success |
The stage that follows. Without it, the next stage in the list |
on_reject |
A stage id, or { to, max_iterations } |
loop |
{ to, on, max_iterations, requires?, title? } (below) |
enqueue_on_enter |
A job type queued in the same transaction as an advance into the stage. The engine never assumes an agent stage enqueues a job |
A loop goes back to an earlier stage when the stage’s outcome equals on. max_iterations is 1 to 100, or { setting: <name> } to read a per-project value. requires is the loop’s own entry check (a loop never checks the target stage’s requires or gate). title names the loop in transition reasons and errors, and defaults to “Loop”.
An on_reject that points backwards is also a loop, so it needs max_iterations.
Reject comments reach the agent (0.9.0). When a stage’s entry gate is rejected and its on_reject re-enters an agent stage, the engine gives that agent the gate’s comment as feedback, for every engine-run pipeline. Gates raised in the middle of a stage (external_action, tool_approval) keep their 0.8.0 behaviour. The agent sees it in its feedback, with any validation findings. The careers pack relies on it: a comment on application_approval goes back to tailor.
Handler output is stored (0.9.0). A top-level handler stage with an output stores StageHandlerResult.Output as a new version of that artifact. Before 0.9.0 the engine stored handler output for map and reduce items only.
Guards before validator agents (0.9.0). See Validator agents.
Constructs added in 0.8.0
0.8.0 adds definition syntax for runs the engine drives itself, for triggers and for the flow shapes other packs need. Each field is optional, and a definition that doesn’t use one hashes as before. The fixture pipelines run each construct end to end on the Fake provider. The engine UI renders them all with no code per pipeline.
A stage uses at most one of parallel, fan_out, map, conversation and variants.
Run control and concurrency
The pack declares in C# whether the host or the engine drives a pipeline’s runs (RunControl.Host or RunControl.Engine, the default). The SDLC is Host, so its pages and endpoints still move its runs. For an engine-controlled pipeline, the generic API starts, cancels, rolls back and retries runs and takes inputs, and the stage.run job moves a run one stage at a time. See Triggers and webhooks.
A project may have one active run of a pipeline at a time. To allow more, set concurrency.runs:
concurrency: { runs: many } # default: one
Triggers
A trigger is manual (the default), schedule or webhook. schedule and webhook run since 0.8.0.
trigger: { kind: webhook, input: session_log, on_active: submit }
| Option | Meaning |
|---|---|
input |
The artifact the webhook body (or the schedule’s inputs) is stored as. It must be declared input: true. A webhook needs it |
on_active |
skip (default) or submit. With skip, a schedule fire is skipped and recorded, and a webhook call is refused with RUN_ALREADY_ACTIVE. With submit, the payload becomes a new version of input on the active run |
A pipeline that takes more than one trigger lists them in triggers: instead of trigger:, with at most one webhook and one schedule:
triggers:
- { kind: manual }
- { kind: webhook, input: session_log }
- { kind: schedule }
The cron expression and timezone are never in the definition. An Owner sets them per project.
Input artifacts and requires
input: true marks an artifact that a person, a webhook or a schedule supplies. A stage that needs it lists it under requires. The driver waits there with run status waiting_on_input, and continues when a version arrives.
artifacts:
session_log: { title: Session log, format: json, schema: session-log.schema.json, approval: auto_lock, input: true }
stages:
- id: analyse
requires:
- { input: session_log }
Input versions are checked against the artifact’s schema. INPUT_INVALID lists the failing paths.
Source-of-truth artifacts
scope: project gives an artifact one version history per project, shared by every run of the pipelines that declare it. People edit and lock it through the artifact endpoints, so no stage may output it.
artifacts:
athlete_profile: { title: Athlete profile, format: json, approval: required, scope: project }
A run pins the newest locked version when it starts and reads that version throughout. A newer version doesn’t change a run in progress. Without a locked version the run can’t start (409 SOURCE_ARTIFACT_MISSING). A project-scope artifact can’t also be input: true.
Parallel stages
parallel groups branches of ordinary stages. The driver starts every branch at once, and the group completes when each branch has finished (join: all).
- id: analysts
title: Analysts
status: analysing
parallel:
id: analysts
join: all
on_branch_failure: fail # or continue
branches:
- - { id: bull, title: Bull analyst, status: analysing, agent: { key: bull-analyst, prompt: flow.bull }, inputs: [ticker], output: bull_case }
- - { id: bear, title: Bear analyst, status: analysing, agent: { key: bear-analyst, prompt: flow.bear }, inputs: [ticker], output: bear_case }
A branch can’t read another branch’s output (DEF_BRANCH_INPUT). It can’t declare veto, gates, routes, aggregates, nested groups, map or conversation. With on_branch_failure: fail a failed branch fails the group. With continue, downstream stages see only the successful outputs.
Veto
veto lists guards or agents that can stop a stage’s output. A veto is stronger than validate: there is no retry. on_veto either routes back to an earlier stage or ends the run.
- id: size
agent: { key: sizer, prompt: flow.size }
agents:
- { key: risk-manager, job_type: flow.risk-review, prompt: flow.risk }
veto:
- { guard: flow.position-limit }
- { agent: risk-manager }
on_veto: { to: propose } # or { end: vetoed }
on_veto is required with veto. A veto agent answers {"findings":[...]} or {"approve":true}. An end: vetoed run is completed with outcome vetoed. The findings are kept on the stage execution.
The findings reach the agent (0.9.0). When on_veto: { to } re-enters an agent stage, that agent’s next attempt gets the findings as feedback: a first line Vetoed at <stage>, then one finding per line.
Fan-out and aggregation
fan_out runs one branch per entry, in parallel, each with isolated context. Name different agents (each bound under agents: with its own prompt and model), or give a count of samples from one agent (2 to 10).
agents:
- { key: forecaster-base-rate, job_type: flow.forecast-base-rate, prompt: flow.forecast-base-rate }
- { key: forecaster-trend, job_type: flow.forecast-trend, prompt: flow.forecast-trend }
fan_out: { agents: [forecaster-base-rate, forecaster-trend] } # or { count: 3 }
A branch’s prompt holds only the stage’s declared inputs and its own context. If a branch’s input contains a sibling’s output (32 characters or more), the branch fails with FANOUT_ISOLATION_BROKEN. A fan-out stage can’t declare routes or on_invalid.then: escalate.
A later stage reads every branch with aggregate. It gets a labelled list. An optional guard flags strong disagreement without failing the stage:
aggregate:
from: forecast # a fan-out, parallel or map stage
disagreement: { guard: flow.forecast-spread }
Routes and the revision cap
An agent stage with routes may send the run back to an earlier stage. Its output then carries a top-level route field: continue or one of the listed ids. A missing or invalid route fails the stage with VALIDATION. The cascade invalidates downstream artifacts, as on_reject does.
The reason reaches the agent (0.9.0). A JSON output may also carry a top-level route_reason string (up to 4,000 characters; longer ones are cut). The agent of the stage a route re-enters gets it as feedback on its next attempt: Sent back by <stage> (route), then the reason. A route with no reason gives Sent back by <stage> with no reason. The feedback is used for that entry only, joins any validation findings, and is secret-redacted.
limits: { revisions: 3, then: escalate } # then: escalate or fail
stages:
- id: edit
agent: { key: editor, prompt: flow.edit }
routes: [research, write]
limits.revisions (1 to 100) counts every backward transition in a run: loops, on_reject, routes and veto to:. The transition that would exceed it is refused, and then applies. Approving an escalation re-runs the stage, and further backward moves are refused again, so each needs a decision.
Feedback on backward moves (0.9.0). When a route or a veto on_veto: { to } moves a run back, the agent of the re-entered stage gets the reason as feedback on its next attempt, as it does for a gate on_reject. The feedback comes before any validate findings and stays for that stage’s retries. The timeline and replay show it as feedback.
Variants
variants produces 2 to 5 outputs of one stage, stored as versions labelled v1 to vn. A person picks one at a variant_select gate, or a selector agent does.
variants: { count: 3, select: gate } # a person picks
variants: { count: 2, select: { agent: tagline-judge } } # an agent picks: { choice, reason }
Only the chosen variant moves downstream. The rest stay, read-only. A choice outside v1 to vn fails with VARIANT_CHOICE_INVALID.
Validator agents
validate accepts agents next to guards. The validator agent must be bound under agents:.
agents:
- { key: fact-checker, job_type: flow.fact-check, prompt: flow.fact-check }
validate:
- { agent: fact-checker }
on_invalid: { retry_with_feedback: true, max_attempts: 2, then: fail }
The validator returns { verdict: pass | reject, findings: [{ path?, claim?, reason, severity: error | warning }] }. error findings reject the output, and on_invalid handles them like guard findings. warning findings are kept. A validator that returns invalid JSON fails the attempt with VALIDATOR_INVALID_OUTPUT. Each validator run is recorded as its own agent run.
Guards run first (0.9.0). On each attempt the stage’s validate: guards run in declared order. If any guard returns findings, the attempt is rejected with those findings, and the validator agents aren’t called for it, so no model call is spent on output the rules already refuse. The validator agents run, in declared order, only when every guard passes. Their findings join the same feedback.
Feedback store
Each agent key in a project has a list of feedback entries. People add them in the UI or API, and a stage can write them. Another stage injects the newest ones into its prompt.
- id: work
agent: { key: worker, prompt: flow.pm-work }
feedback: { inject: true, limit: 10 } # newest first; at most 50
- id: review
agent: { key: reviewer, prompt: flow.pm-review }
writes_feedback: { agent: worker, from: lessons } # one entry per string in output.lessons
The prompt placeholder is optional, so a first run with no entries renders it empty. The agent run records which entries it used.
Since 0.9.0, writes_feedback also takes a list, so one output can write entries for several agents. Each agent key may appear once (DEF_DUPLICATE_ID). The single-object form still works and hashes as before. writes_feedback also works on follow-up stages, which read their own labelled output.
writes_feedback:
- { agent: bull, from: lessons_bull }
- { agent: bear, from: lessons_bear }
Follow-up stages
followups queue a stage some time after the run completes. The stage is declared like any other, but the main flow never reaches it.
followups:
- { stage: grade, after: [1d, 5d, 20d] }
Durations are <n>d, <n>h or <n>m, counted in absolute time from completed_at (1d is 24 hours). Each follow-up stores its output with the label followup:<duration>. The run stays completed. Cancelling a completed run cancels its pending follow-ups. A follow-up stage is a plain agent or handler stage with an output, and it can’t offer destructive or external tools (DEF_FOLLOWUP_STAGE). A handler follow-up’s output is stored with the same label.
Repeating follow-ups (0.9.0). A handler follow-up can repeat with every and for instead of after:
followups:
- { stage: resolve, every: 1d, for: 400d }
Check n is due at completed_at + n × every, so a late check doesn’t move the later ones. The last check is the largest n with n × every ≤ for. Each check is labelled followup:<every>#<n>. The handler’s result decides what happens next:
Waiting: the next check is queued.Completed: it stops.Failed: the failure is recorded (the check’s job fails with the handler’s error) and the next check stays due. Three failures in a row stop it withfollowup_failed.- When the next check would fall after
completed_at + for, it stops, and that check recordsfollowup_expired.
A check that runs late (the worker was down) stands for the checks it missed, so each runs once. Cancelling the completed run cancels the pending check, and closes a check that is running as cancelled. Handlers get a FollowUpFact (label, check number, completed_at) and an OutcomesFact (see Outcomes recorded by a handler). Only handler stages repeat. every is at least 1h, and for is between every and 400d (DEF_FOLLOWUP_REPEAT).
In the run DTO (GET /api/pipeline-runs/{runId}), a repeating follow-up’s row in followUps is check 1, and adds:
checks: each check that has run,{ check, label, dueAt, stageExecutionId, enteredAt, exitedAt, outcome }(outcomewaiting,failedor the end state);nextDueAt: when the pending check is due (null while a check runs, and once it has stopped);endState:completed,followup_expired,followup_failedorcancelledonce it has stopped, else null.
One-off follow-ups leave all three null.
Outcome scores
Scores can be free-form or declared. A free-form score is posted to POST /api/pipeline-runs/{runId}/outcomes with a target (an agent run, or an artifact version), a metric and a value. The probability_brier kind needs a prediction from 0 to 1 and a value of 0 or 1, and the engine stores (prediction minus value) squared. The prompt comparison shows the mean score per metric for each agent key and prompt version. A follow-up prompt can read the scores.
Declared outcomes (0.9.0)
A definition can declare the metrics a person records later, so the engine finds the target and the prediction itself. The block is top-level:
outcomes:
- metric: interview
title: Got an interview
kind: probability_brier
target: { stage: assess }
prediction: { artifact: fit_assessment, path: interviewProbability }
- metric: offer_count
title: Offers received
kind: number
target: { stage: assess }
| Field | Meaning |
|---|---|
metric |
The name. Letters, digits, _ or -, in lower case, at most 100 characters. Unique in the definition |
title |
The label the Outcomes panel shows |
kind |
probability_brier or number |
target.stage |
The stage whose output is scored (see the targets below) |
prediction |
{ artifact, path }: the value to score, read at a dot-separated path in the target stage’s output. Required for probability_brier, and not allowed for number |
A number outcome stores the value as given, with no prediction. The definition’s DTO carries the block. A definition with no outcomes: hashes as before.
Targets. From 0.9.0 M78 (FR-396), target.stage may be any of these:
| Target stage | What is scored | The score is about | branch |
|---|---|---|---|
| Agent stage | Its newest current output | The agent run that produced it | null |
| Fan-out stage | Each branch’s newest current output | Each branch’s agent run | The agent key, or sample-<n> for count: |
| Handler stage with a JSON output | Its newest current output version | The artifact version (there is no agent run) | null |
| Variants stage | The selected variant | The agent run that produced it | null |
A fan-out metric is recorded once, and stores one score per branch that has a current output with a prediction. Branches without one are skipped. If every branch is skipped, recording gives 409 OUTCOME_TARGET_MISSING. Each branch’s score counts toward its own agent key in the prompt comparison.
Validator codes.
| Code | When |
|---|---|
DEF_OUTCOME_TARGET |
target.stage is missing or isn’t a stage, or has no output. A parallel group, map, conversation, follow-up or manual stage is not allowed, nor a handler stage whose output isn’t JSON. Also when prediction.artifact isn’t that stage’s output or isn’t a JSON artifact, or prediction.path isn’t a dot-separated path |
DEF_OUTCOME_KIND |
probability_brier has no prediction, or number has one |
DEF_OUTCOME_METRIC |
A metric name is missing, malformed, too long or declared twice |
Record one. A Contributor posts the declared form to the same route:
{ "metric": "interview", "value": 1, "observedAt": "2026-12-08T00:00:00Z", "note": "Phone screen booked" }
observedAt and note (at most 2,000 characters) are optional. The engine finds the target’s current output (not superseded, invalidated, rejected or corrupted), as the Targets table says. It reads the prediction from that output and stores the score with source user:<id>. Active and completed runs both accept outcomes. For a fan-out metric the response is the first branch’s score, and the list has them all.
- Superseding. Recording a metric again supersedes the run’s earlier score for it (for a fan-out metric, every branch’s). The old score is kept, with a
supersededAttime, so a correction doesn’t average with the mistake. Prompt comparison,with_outcomesand follow-upuse only current scores, andshows a branch score asmetric (branch): score. - Example. With
interviewProbability0.7, recordinginterview = 1stores 0.09. Recordinginterview = 0afterwards stores 0.49 and supersedes the first. - Errors. An undeclared metric, or a value other than 0 or 1 for
probability_brier, gives 400VALIDATION. A run with no current output of the target stage gives 409OUTCOME_TARGET_MISSING. So does a missing prediction, or one outside 0 to 1. After a rollback invalidates the output, recording gives 409 until the stage runs again. Two records at the same moment can give 409CONFLICT.
GET /api/pipeline-runs/{runId}/outcomes lists the scores, each with supersededAt, declared and branch (the fan-out branch, else null). A run of a pipeline with declared outcomes shows an Outcomes panel in the engine UI, with the metric’s title, its value (yes, no or not recorded) and a change control for Contributors.
Outcomes recorded by a handler (0.9.0)
A handler can record declared outcomes itself (FR-395), in a main-flow stage or a follow-up. It returns them with its result:
return new StageHandlerResult(StageHandlerOutcome.Completed)
{
Outcomes = [new OutcomeObservation("hit", 1) { Note = "Resolved yes" }],
};
Each { metric, value, observedAt?, note? } is recorded as a person’s record is (the same targets, rules and superseding), with source stage:<stageId>. A main-flow handler records when it completes. A follow-up check records when it completes or answers Waiting, so a repeating check can record each outcome as it is reached. A Failed result records nothing.
- An undeclared metric, a bad value, or the same metric twice in one result fails the stage with
VALIDATION. - A metric whose target or prediction is missing is skipped. The stage doesn’t fail, and its execution notes
OUTCOME_TARGET_MISSING: <reason>inoutcomeNotes(on the timeline’s stage entry; these aren’t veto findings). A map item or reduce handler that returns outcomes fails withVALIDATION. - A redelivered job doesn’t record the same outcome twice.
Every handler stage gets the run’s current declared scores as an OutcomesFact: Scores: [{ metric, branch, value, score }], plus Has(metric). A repeating handler uses it to skip metrics it has already recorded.
Map-reduce
map runs one isolated agent or handler execution per element of an array in a JSON artifact. An optional reduce stage gets every item output.
- id: score
output: scores
agents:
- { key: qa-scorer, job_type: flow.qa-score, prompt: flow.qa-score }
- { key: qa-summariser, job_type: flow.qa-summarise, prompt: flow.qa-summarise }
map: { over: transcripts.items, agent: qa-scorer, max_parallel: 8, max_items: 1000, on_item_failure: skip, max_failed: 5% }
reduce: { agent: qa-summariser }
| Field | Meaning |
|---|---|
over |
<artifact key>.<array path>, or a bare key when the artifact is the array. The artifact must be JSON and readable by the stage |
max_parallel |
1 to 100 items at a time (default 8) |
max_items |
1 to 1000 (default 1000). More elements fail the stage with MAP_TOO_MANY_ITEMS, and no item runs |
on_item_failure |
skip (default) or fail |
max_failed |
A count or a percentage of the total, rounded down (default 5%). More failures fail the stage |
A map stage has no agent: or handler: of its own and needs an output. Items run in index order. The UI shows a progress bar and a paged item list.
Conversation
conversation runs a turn-based exchange between two to six agents. Each turn is one agent run, given its own prompt and the transcript so far. The output artifact is the transcript.
- id: call
output: transcript
agents:
- { key: customer-sim, job_type: flow.callsim-customer, prompt: flow.callsim-customer }
- { key: support-sim, job_type: flow.callsim-support, prompt: flow.callsim-support }
conversation:
participants:
- { agent: customer-sim, role: customer }
- { agent: support-sim, role: agent }
opener: customer
max_turns: 6
stop: { phrase: goodbye } # or { guard: pack.name }
Turns go in order from the opener, cycling. After each turn the engine checks the stop phrase (case-insensitive), then the stop guard, then max_turns (1 to 100). A role or an agent can’t repeat (DEF_CONVERSATION_PARTICIPANTS).
Windowed inputs over runs
An input of from_runs collects an artifact from the project’s earlier runs of a pipeline. With a schedule trigger it gives weekly reports.
inputs:
- from_runs: { pipeline: fixture-qa, artifact: scores, window: 7d, status: completed }
It takes the newest version of the artifact from each matching run that ended in the window, newest first, up to 1,000 runs. status is completed (default), failed or cancelled. The current run is excluded, and a version that fails its integrity check drops out.
with_outcomes (0.9.0). Add with_outcomes: true to also collect each run’s recorded outcomes:
inputs:
- from_runs: { pipeline: job-application, artifact: application_record, window: 30d, status: completed, with_outcomes: true }
Each list item then carries outcomes: [{ metric, value, prediction?, score, observedAt, branch? }]: the current (not superseded) declared score for each metric, one per branch for a fan-out target (branch is the agent key or sample-<n>, and agents see it as - <metric> (<branch>): …). It reads the declared scores stored for each run, not that run’s definition. A handler gets the list in RunsInputFact, and an agent gets it in ``. Without the flag, items carry no outcomes, and the definition hash doesn’t change.
Tool tiers and external actions
A pack registers every tool with a tier: read, write or destructive. A tool registered without one is write. A stage offers tools up to its tool_policy.max_tier, which defaults to write. The SDLC’s repo tools are read.
agent: { key: executor, prompt: flow.oncall-execute, tools: [flow.read-logs, flow.restart-pod] }
tool_policy: { max_tier: destructive }
A listed tool above max_tier is DEF_TOOL_TIER. At call time the runner also refuses a tool the stage wasn’t offered. A binding under agents: sets its own tool_policy, with no inheritance.
Two kinds of call always wait for an Owner’s approved gate, in every approval mode, autonomous included:
| Case | Gate | Reject, or no decision in 24 hours |
|---|---|---|
The model calls a destructive tool |
tool_approval, raised mid-stage with the tool, its redacted arguments and the agent’s reason. The loop state is saved and resumes after the decision |
The model receives denied by <user>: <comment> and carries on |
A handler or tool registered external: true (it sends, publishes, submits or pays outside Tevrin) |
external_action, raised just before it, showing the exact payload |
The stage fails with EXTERNAL_ACTION_REJECTED, or follows its on_reject |
external and the tier are registration flags in pack code, not YAML. The tier is only as honest as the pack’s registration, so register anything that changes outside state as destructive or external.
Prompt placeholders
| Placeholder | Available to | Holds |
|---|---|---|
{{<KEY>_ALL}} |
Aggregate and reduce agents | Every branch or item output, labelled |
{{AGENT_FEEDBACK?}} |
Stages with feedback |
The injected feedback entries, one per line |
{{MAP_ITEM}}, {{MAP_INDEX}} |
Map item agents | The element and its 0-based index |
{{TRANSCRIPT}}, {{ROLE}} |
Conversation participants | The turns so far, and this participant’s role |
{{<ARTIFACT>_RUNS}} |
Stages with from_runs |
The collected versions, one per run |
{{OUTCOME_SCORES}}, {{VARIANT}} |
Follow-up stages | The run’s scores, and the follow-up label |
Validator codes
The validator reports every problem at once, each with a code and the YAML path, for example DEF_UNKNOWN_GUARD at stages[1].validate[0].guard.
| Code | When |
|---|---|
DEF_PARSE |
The YAML doesn’t parse, a key has the wrong type, or a value is out of range |
DEF_DUPLICATE_ID |
Two stages, artifacts, statuses or status changes share an id, or a writes_feedback list names an agent twice |
DEF_UNKNOWN_STAGE, DEF_UNKNOWN_ARTIFACT, DEF_UNKNOWN_STATUS |
A reference names something not declared |
DEF_UNKNOWN_GUARD, DEF_UNKNOWN_HANDLER, DEF_UNKNOWN_TOOL, DEF_UNKNOWN_JOB_TYPE |
No pack registered that name |
DEF_UNKNOWN_PROMPT |
An agent stage’s prompt isn’t one its pack registered, doesn’t parse, requires {{FEEDBACK}}, or needs a placeholder that is neither a stage input nor a registered context name. Checked only for a pack that registers prompts |
DEF_STAGE_KIND |
A stage has both agent and handler, or combines more than one of parallel, fan_out, map, conversation and variants, or uses a construct on the wrong kind of stage (for example routes on a fan-out stage, reduce without map) |
DEF_UNREACHABLE_STAGE |
No path from a start stage reaches it |
DEF_UNCAPPED_LOOP |
A loop, a backward on_reject or a backward on_success has no max_iterations |
DEF_LOOP_FORWARD |
loop.to isn’t an earlier stage |
DEF_SCHEMA_NOT_FOUND |
schema names a file the pack doesn’t embed, or it isn’t valid JSON Schema |
DEF_ARTIFACT_NO_PRODUCER |
An artifact is read but no stage outputs it and no pack declares a producer |
DEF_UNKNOWN_SETTING |
{ setting: x } names a setting not in settings |
DEF_TRIGGER_NOT_SUPPORTED |
A trigger option its kind doesn’t take, such as cron in a definition (cron belongs to the per-project schedule) or any option on a manual trigger. Since 0.8.0 schedule and webhook themselves are supported |
DEF_BRANCH_INPUT |
A stage in one branch of a parallel group reads an artifact another branch produces |
DEF_ROUTE_TARGET |
A routes entry or on_veto.to is unknown, the stage itself or a later stage |
DEF_TOOL_TIER |
A listed tool’s tier is above the stage’s tool_policy.max_tier (default write) |
DEF_FANOUT_AGENT |
An agent key used by fan_out, veto, variants, validate, map, reduce or conversation isn’t bound under agents:, or a writes_feedback agent isn’t declared by any stage |
DEF_MAP_SOURCE |
map.over isn’t <artifact key>.<array path>, names an undeclared or non-JSON artifact, or one the stage can’t read |
DEF_CONVERSATION_PARTICIPANTS |
A conversation has too few or too many participants, a repeated role or agent, or an unknown opener |
DEF_FOLLOWUP_STAGE |
A followups stage isn’t top-level, is listed twice, is reached by the main flow, isn’t an agent or handler stage with an output, offers a destructive or external tool, or has a bad after duration |
DEF_FOLLOWUP_REPEAT |
A repeating follow-up (every, for) is on an agent stage, also has after, lacks every or for, has every under 1h, or has for outside every–400d (0.9.0) |
DEF_SCOPE_INPUT |
A scope: project artifact is produced by a stage, gate or handler, is also input: true, or two pipelines declare the same key differently |
DEF_OUTCOME_TARGET, DEF_OUTCOME_KIND, DEF_OUTCOME_METRIC |
An outcomes: entry has a bad target, kind or metric (0.9.0, see Declared outcomes) |
These are start-up and readiness errors, not API errors. See Pipeline definitions.
Hash and pinning
Each definition has a hash: the SHA-256 of its canonical JSON. The canonical JSON is the parsed model with keys sorted and no extra whitespace. Comments, key order and formatting don’t change the hash, and any changed value does. Defaults (such as an artifact’s format: markdown) are written into the canonical JSON, so writing one out explicitly doesn’t change the hash.
The canonical JSON escapes only the quote, the backslash and control characters U+0000 to U+001F. Every other character is raw UTF-8, so the hash doesn’t depend on the .NET version.
The first time a hash is used, its canonical content is stored in pipeline_definitions. A run stores the hash it started with and always loads that stored definition. Editing the YAML therefore never changes a run in progress. If the stored definition names a guard, handler or tool the current build no longer registers, moves on that run return 409 DEFINITION_UNAVAILABLE. Reads still work.
Extension points
A pack implements IPipelinePack (an Id and Register(IPackRegistry)). Registering names tells the validator what exists. The implementations are bound by name in the host’s DI.
| Extension point | Registered with | Used for |
|---|---|---|
| Definition, schema, prompt | AddDefinition, AddSchema, AddPrompt |
Embedded YAML, JSON Schema and prompt templates |
IGuard |
AddGuard("pack.name"), then AddPipelineGuard<T>("pack.name") |
requires and validate checks. Returns pass, or the reasons it failed |
IStageHandler |
AddStageHandler, then AddPipelineStageHandler<T> |
Code stages |
IAgentTool |
AddTool (with a tier: read, write or destructive, and external), then AddPipelineTool<T> |
Tools an agent stage lists in agent.tools |
| Job types | AddJobType |
Types the pack’s job handlers process |
| Settings | AddSetting, plus an IRunSettingsProvider |
Per-project values for { setting: x } |
| Artifact producers | AddArtifactProducer |
A key that a job (not a stage) writes |
IAgentContextProvider |
AddContextName plus a DI service |
Extra prompt context |
IInvalidationHook |
A DI service | Pack effects when an approval invalidates artifacts (the SDLC resets steps) |
IRunStartSelector |
A DI service | Choosing among several start stages |
RunControlOf |
A member of IPipelinePack |
RunControl.Engine (default) or RunControl.Host per pipeline |
Guard, handler and tool names start with the pack id (sdlc.plan-has-steps). A malformed or wrongly namespaced name throws when the pack registers. The host calls AddPipelineRegistry() and AddPipelinePack<T>() once.
Writing a guard
- Add the name in your pack’s
Register:registry.AddGuard("coach.velocity-load-rules"). - Implement
IGuard.EvaluateAsyncreturnsGuardResult.Pass, orGuardResult.Fail(...)with user-facing reasons. - Bind it in the host:
services.AddPipelineGuard<VelocityLoadRulesGuard>("coach.velocity-load-rules"). - Use it in the definition under
requiresorvalidate.
A validate guard receives the stage’s output as a StageOutputFact in context.Facts. Without step 1 the validator reports DEF_UNKNOWN_GUARD.
Validate and retry
When a guard or the artifact schema rejects an agent’s output, the stage reruns the agent with the findings appended as feedback, up to max_attempts. The findings are the guard’s reasons followed by schema errors (path and message), capped at 8,000 characters. After the last attempt, then: escalate raises an escalation gate on the run, and then: fail marks the agent run and its job failed. With max_attempts: 3 and then: escalate, three failing attempts give three agent runs, two with feedback, and one pending escalation gate.
The SDLC as the first pack
sdlc.pipeline.yaml holds the lifecycle: Analysis (a start stage only), Refinement, Specification, Planning, Execution, Review and Release. Its entry gates, statuses and the review loop equal the 0.6.1 rules, and SdlcLifecycleTransitionTests keeps a unit test for every allowed and forbidden transition. The characterisation snapshots under backend/tests/Tevrin.IntegrationTests/Characterisation/Snapshots/ record the whole flow, and CI fails if any changes (scripts/ci/check-snapshots-frozen.sh).
In 0.7.0 the SDLC runs on the engine runner. All eight SDLC agents run as agent stages, or as agents bound to a stage (agents:), through the same AgentStageRunner that new packs use. The SDLC adds its own hooks, context providers and tools (SdlcAgentExtension), so the prompts, run records, events, retries and error codes stay the same as in 0.6.1. Golden prompt tests pin the prompts. 0.6.1’s separate SDLC runner has been removed. A project that predates pipeline runs gets its run when an agent first needs one.
Not supported yet
- Changing the SDLC’s runs: they stay host-controlled through the project endpoints.
- Product packs other than the SDLC, coach, careers, studio, forecasting and markets packs. The other constructs are proven on fixture pipelines only, and no pack ships a destructive tool.
- Unordered many-agent conversations and a shared environment (the “agent economy”). Conversations are turn-based, with two to six participants.
- Uploading or editing definitions at runtime. Definitions ship inside pack assemblies.
- Packaging (NuGet and npm packages, a pack template, command-line tooling).
- Re-running a recorded run against a new prompt version. Replay is read-only.
Packages
The loader uses YamlDotNet 18.1.0 and the schema check uses JsonSchema.Net, pinned at 8.0.5 because later releases use a commercial licence. Both are referenced by Tevrin.Engine.Runtime only.
See also Architecture and Pipeline definitions.
Other packs
Since 0.8.0 a second pack, coach (Tevrin.Pack.Coach), runs the impulse-coach pipeline. It holds only YAML, schemas, prompts and its Velocity guard, and it references only Tevrin.Engine.Domain. See the Impulse coaching pack guide. To start runs, schedule them or call them from another system, see Triggers and webhooks.
Since 0.9.0 a third pack, careers (Tevrin.Pack.Careers), runs the job-application and job-digest pipelines. It holds YAML, schemas, prompts, and its guards and handlers as pure code, and it references only Tevrin.Engine.Domain. It needed the engine additions above: declared outcomes, with_outcomes, guards before validator agents, reject comments as feedback and stored handler output. See the Job applications pack guide.
Also in 0.9.0, the studio pack (Tevrin.Pack.Studio) runs the content-studio pipeline: a YouTube script grounded in pasted sources, with editor routes, three title and thumbnail variants and a publish review. It references only Tevrin.Engine.Domain and uses the engine additions for the packs: route feedback, the revision cap and a variants-stage outcome target. See the Content studio pack guide.
Also in 0.9.0, the forecasting pack (Tevrin.Pack.Forecasting) runs the forecast and forecast-calibration pipelines: three isolated forecasters on a binary Polymarket market, a deterministic combine with a spread warning, a daily resolution check that records Brier scores, and a calibration report. It references only Tevrin.Engine.Domain and makes no network calls: the host’s read-only Polymarket adapter implements its IPredictionMarketSource. It uses the engine additions for the packs: a repeating handler follow-up, handler-recorded outcomes and per-branch outcome targets. See the Forecasting desk pack guide.
Also in 0.9.0, the markets pack (Tevrin.Pack.Markets) runs the market-research pipeline: a price snapshot with a universe veto, a scanner, bull and bear cases in parallel and then rebuttals, grounding rules on every point, a portfolio manager checked against the desk’s risk limits with a risk manager’s veto, an optional review gate, and a paper decision record. A repeating follow-up grades it over 20 trading days, and a 32-day post-mortem writes lessons as feedback for later runs. It references only Tevrin.Engine.Domain and makes no network calls: the host’s read-only Alpaca adapter implements its IPriceHistorySource. Nothing is traded. See the Market research desk pack guide.