/** * Skill Provenance helpers * * Surfaces metadata about a learned `BrowsingSkill` (when it was * created, when it was last successful, success/failure counts) on * the browse result so downstream callers can apply freshness and * quality policies without reaching into ProceduralMemory themselves. * * The shape mirrors the underlying `BrowsingSkill.createdAt` / * `updatedAt` / `metrics.*` fields exactly so the copy is lossless. * * Lives in its own module (not inside smart-browser.ts) so: * 1. The unit test can import it directly without booting the * full smart-browser dependency graph (Playwright, learning * engine, procedural memory, etc.) * 2. The two assignment sites in smart-browser.ts can call the * same function instead of duplicating the inline copy * 3. Future code that needs the provenance shape (e.g. the * planned /v1/verify endpoint) has a single shared definition */ import type { BrowsingSkill } from '../types/index.js'; /** * Provenance fields surfaced on `SmartBrowseResult.learning.skillProvenance`. * * IMPORTANT semantics: * * - `createdAt`: when the skill was first recorded. Stable. * * - `updatedAt`: when the skill record was last touched by ANY write. * Note that ProceduralMemory.recordSkillExecution bumps this on * every execution, so in steady-state traffic this tracks "last * activity" rather than "last definition edit." Don't use this * field as a proxy for "definition is stale." * * - `lastUsedAt`: timestamp of the most recent invocation, success * OR failure. A skill that's been recently attempted but failing * will still have a recent `lastUsedAt`. Use `lastSuccessAt` if * you specifically want "last success." * * - `lastSuccessAt`: timestamp of the most recent SUCCESSFUL * invocation. 0 (sentinel) if the skill has never succeeded. * This is the field for "is this skill actually working" policies. * * - `successCount` / `failureCount`: cumulative counts. Together * they enable success-rate policies (`successCount / (successCount * + failureCount)`). */ export interface SkillProvenance { createdAt: number; updatedAt: number; lastUsedAt: number; lastSuccessAt: number; successCount: number; failureCount: number; } /** * Copies provenance fields off a `BrowsingSkill` into the wire shape * surfaced on browse results. Pure function — used by smart-browser.ts * at every site that assigns `learning.skillApplied`, and exercised * directly by the unit tests. * * Defensive against legacy data: `lastSuccess` was added in a later * version, so older serialized skills may not carry it. We default * to 0 here even though setSkill() already normalizes — belt and * suspenders, since this function is also called on synthetic skills * constructed in tests. */ export declare function copySkillProvenance(skill: BrowsingSkill): SkillProvenance; //# sourceMappingURL=skill-provenance.d.ts.map