import type { ScannerDefinition } from "../scanner-definition.js"; import type { ScannerScanOutput } from "../types.js"; import type { ScanContext, ScannerInitContext } from "./context.js"; import type { ScannerHooks } from "./hooks.js"; /** * Core scanner contract implemented by all strategy-runtime scanners. * * Each scanner declares a {@link ScannerDefinition} describing its identity, * provider-backed inputs, shared market intelligence contracts, scheduling interval, and persistence/retention policies. The engine * calls {@link initialize} once per (address, scannerId) registration, then * calls {@link scan} on each scheduled or manual run. Push-driven scanners may * declare `definition.scheduleMode = "external"` so the runtime can register * them without interval scheduling. * * **Lifecycle:** * 1. Engine loads/creates runtime state and builds an init context. * 2. `initialize(ctx)` is called once — use it to bootstrap scanner-local state * or validate prerequisites. The init context provides `setState()` for persisting * initial state and `loadSharedArtifact()` / `saveSharedArtifact()` for shared market intelligence. * 3. On each run, the engine builds a scan context with resolved provider-backed * inputs plus shared market intelligence under `ctx.inputs.artifacts`. * 4. If `hooks.beforeScan` is defined, it runs first and may throw `SkipScan` to abort. * 5. `scan(ctx)` executes scanner logic and returns signals + metadata. * 6. The engine normalizes scores to [0, 1], applies `hooks.isActionable` filtering, * and persists results according to the scanner's policies. * * @typeParam Cfg - Scanner configuration type (validated against `definition.configSchema`). * @typeParam St - Scanner-local mutable state type (persisted across runs via `ctx.setState()`). */ export interface Scanner { /** Static scanner metadata: identity, input contracts, scheduling, persistence. */ definition: ScannerDefinition; /** Optional pre/post-scan behavior customizations. */ hooks?: ScannerHooks; /** * Called once per (address, scannerId) registration before the first scan. * Use this to initialize scanner-local state, validate config, or load prerequisites. * The context provides `setState()` for persisting initial state to disk. */ initialize: (ctx: ScannerInitContext) => Promise; /** * Executes one scanner run and returns signals with execution metadata. * The context includes resolved provider-backed inputs, shared market intelligence, * current config/state, and shared artifact accessors. Signals returned here are normalized by the * engine (score clamping, factor coercion) before persistence. */ scan: (ctx: ScanContext) => Promise; } //# sourceMappingURL=scanner.d.ts.map