Expand description
Time-Traveling Stream Rules engine. TTSR (Time-Traveling Stream Rules) engine.
Monitors streaming model output against project rules. When a rule is violated, the stream is aborted and the rule is injected as a system reminder so the model can correct itself.
Ported from omp packages/coding-agent/src/export/ttsr.ts (TtsrManager).
Two matching modes are supported:
- Regex: the original
conditionfield, matched against streaming deltas. - AST: the optional
ast_conditionfield, matched against file content after tool writes via theTtsrAstMatcher. AST matching shells out to thesg(ast-grep) CLI in the default build — same dependency surface ascrate::tools::ast_grep.
Structs§
- AstRule
- One AST rule: the subset of a
Rulethat theTtsrAstMatchercares about. Decoupled fromRuleso AST evaluation is independent of regex compilation and so the matcher can be reused without a full rule registry. - Rule
- A single TTSR rule.
- Ttsr
AstMatcher - AST condition matcher: holds a list of
AstRules, dedups by file digest, and delegates actual pattern matching to an injectableAstMatcherFn. - Ttsr
Engine - TTSR engine that buffers streaming deltas and checks them against registered rules.
- Ttsr
Match Context - Context passed to
TtsrEngine::check_deltadescribing what is being generated right now. - Ttsr
Settings - Knobs for the TTSR engine.
Enums§
- Interrupt
Mode - Interrupt mode controlling which stream sources TTSR inspects.
- Match
Source - Which stream source produced a delta.
- Rule
Source - Where a rule originated.
- Scope
Token - Which source produced a TTSR match.
Traits§
- Rule
Registry - Registry of TTSR rules (supplied by the host).
Type Aliases§
- AstMatcher
Fn - Function signature for the underlying pattern matcher. Given an
ast-grep pattern and the file content, return
trueif the pattern matches at least one node in the content.