/** * TriggerRegistry - operator-owned persistence for agent-authored triggers. * * The agent authors triggers (trigger-author.ts); this store only persists/lists them. * Ports Kagemusha `WorkflowContractRegistry` * (~/project/mama-suite/apps/kagemusha/src/agent/contracts/workflow-registry.ts) but with the * human-approval lifecycle removed: `create` yields `status:'active'` immediately (G4 unfrozen). * There is no `needs_review`/`approvedBy` - that gate does not exist here by construction. * * Personal triggers live in the operator DB under `~/.mama`; this source is generic. */ import type { SQLiteDatabase } from '../sqlite.js'; import type { CreateTriggerInput, TriggerRecord } from './trigger-types.js'; export declare class TriggerRegistry { private db; constructor(db: SQLiteDatabase); private runMigration; /** * Existing fired rows were already reviewed repeatedly by the legacy loop. Baseline them at * their current fire count so an upgrade cannot immediately fan out one review call per row. */ private migrateReviewWatermark; /** Persist an agent-authored trigger. Self-activates (G4): status is 'active' at birth. */ create(input: CreateTriggerInput): TriggerRecord; listActive(): TriggerRecord[]; /** Active triggers with fire evidence that has not yet reached the review pass. */ listReviewCandidates(limit?: number, nowMs?: number): TriggerRecord[]; /** Advance the durable review watermark only after a review decision was applied. */ markReviewed(id: string, fired: number): void; /** Back off a failed provider/parse attempt without blocking later review candidates. */ recordReviewFailure(id: string, nowMs?: number): void; /** A provider outage or poison author window must not be resent on every cadence. */ canAttemptAuthor(nowMs?: number): boolean; /** Persist a process-independent exponential backoff for the structured author call. */ recordAuthorFailure(windowFingerprint: string, nowMs?: number): void; /** A successful author decision clears the provider/parse failure streak. */ clearAuthorFailure(): void; /** Every trigger regardless of status (owner tray view). id DESC breaks same-ms ties. */ listAll(): TriggerRecord[]; getById(id: string): TriggerRecord | null; /** * Record that a trigger FIRED (read-only surface loop) - bumps `fired` only. * Distinct from recordOutcome: a fire is not a success/failure judgment, and the * read-only loop must never fabricate one (M1-T2). */ recordFire(id: string): void; /** Record an intervention outcome - the G2 evolution feed (Task 4 reads stats). */ recordOutcome(id: string, outcome: 'succeeded' | 'failed'): void; /** Retire a trigger (agent-judged in Task 4; here it's the mechanical write). */ disable(id: string, reason: string): TriggerRecord; /** Agent retirement must never overwrite a durable owner disable that won the race (TG-06). */ retireActive(id: string, reason: string): TriggerRecord; /** Disable the original and insert its replacement as one rollback-safe decision. */ refine(id: string, reason: string, replacement: CreateTriggerInput): TriggerRecord; close(): void; } //# sourceMappingURL=trigger-registry.d.ts.map