/** Native KERN handler body eligibility classifier — slice 5a foundation * (slice α-3 update: delegates to the AST walker in * `native-eligibility-ast.ts`; slice α-4: diagnostic surfaces at `warning`). * * Given a raw `<<<...>>>` handler body, determines whether it could compile * under `lang="kern"` opt-in WITHOUT manual rewrite. Used by: * * 1. The compiler diagnostic layer (`parser-validate-native-eligible.ts`) * to surface `warning`-level `NATIVE_KERN_ELIGIBLE` hints suggesting opt-in. * 2. The `kern migrate native-handlers` CLI (slice 5b) to bulk-convert. * 3. Empirical scans of real-world repos (e.g. Agon-AI) to measure the * practical adoption ceiling for native bodies. * * Slice α-3: replaced the regex pre-screen with a TS-AST walk that mirrors * the migrator's `mapStatement` rules. Eligibility now equals migrate-success * by construction — the prerequisite for slice α-4's promotion of * `NATIVE_KERN_ELIGIBLE` from `info` to `warning` without producing * fix-or-suppress noise on bodies the migrator silently bails on. * * The legacy regex disqualifier set lives at `LEGACY_NEG_PATTERNS` for * consumers that need a fast pre-filter (no TS parse). The canonical * classifier (`classifyHandlerBody`) uses the AST walker. */ /** A capability that classifies a raw handler body for `lang="kern"` * eligibility. Browser-safe signature (no `ts.*` types). Implemented by the * TypeScript-AST walker `classifyHandlerBodyAst`. */ export type HandlerBodyClassifier = (rawBody: string, opts?: { allowNonBlock?: boolean; }) => EligibilityResult; /** Result of classifying a single handler body. */ export interface EligibilityResult { /** True iff the body uses ONLY syntactic patterns that lang=kern supports. */ eligible: boolean; /** When eligible: `'empty'` (whitespace-only body) or `'ok'` (passed AST walk). * When ineligible: a kebab-case slug naming the first blocking shape — * e.g. `'var-destructure'`, `'try-finally'`, `'expr-stmt-mutation'`, * `'comments-present'`, `'ts-parse-error'`. See * `native-eligibility-ast.ts` for the full set. The legacy regex source * (e.g. `'\\bfor\\s*\\('`) is no longer surfaced — older callers that * switched on the regex string need to migrate to the new slugs. */ reason: string; } /** A raw `<<<…>>>` handler body extracted from a `.kern` source file, * with line positions for diagnostic anchoring. */ export interface RawBody { /** Body content between `<<<` and `>>>` (no surrounding fence lines). */ text: string; /** 1-indexed line number of the `<<<` opener. */ startLine: number; /** 1-indexed line number of the `>>>` closer. */ endLine: number; /** Raw opener text before `<<<`, when present. */ opener?: string; /** Parsed `lang=` value from the opener, when present. */ declaredLang?: string; /** Parsed `reason=` value from the opener, when present. */ declaredReason?: string; } /** Aggregate eligibility report for a single file. */ export interface FileEligibilityReport { totalBodies: number; eligibleBodies: number; /** Per-body classification with line positions. Same length + ordering * as the bodies returned by `extractRawBodies(content)`. */ bodies: Array; } /** Slice α-3: legacy regex disqualifier set. Kept exported for fast * pre-filtering (no TS parse) in tools that don't need precise reasons — * e.g. histogram scanners that only want a coarse "ineligible" signal. * The canonical classifier (`classifyHandlerBody`) no longer uses this set; * it delegates to the AST walker in `native-eligibility-ast.ts`. */ export declare const LEGACY_NEG_PATTERNS: ReadonlyArray; export declare function isExplicitForeignRawBody(body: Pick): boolean; /** Classify a single raw body. Slice α-3: delegates to the AST walker so * eligibility ≡ migrate-success by construction. Slice 0.9: the AST walker is * injected (`classify`) instead of statically imported, keeping this module * browser-safe. Node callers pass `classifyHandlerBodyAst`; the convenience * binding lives at `@kernlang/core/node`. */ export declare function classifyHandlerBody(classify: HandlerBodyClassifier, rawBody: string, opts?: { allowNonBlock?: boolean; }): EligibilityResult; /** Walk a `.kern` source file's text and pull out every `<<< … >>>` body, * preserving line positions. Mirrors the behaviour of `parser-core.ts` * `parseLines`: handles three shapes the parser accepts — * * 1. Inline single-line: `handler <<< return 1; >>>` * 2. Open + close on diff: line ends with `<<<`, body lines, `>>>` line * 3. Tail-content close: open line, body lines, `body; >>>` (close on * same line as last body content) * * Older versions of this extractor only matched shape 2, which made * inline handlers invisible to scanners — `parseLines` was happy to * parse them, but the future codemod (slice 5b) would never see them. */ export declare function extractRawBodies(content: string): RawBody[]; /** Convenience: classify every raw body in a file's content and aggregate * the totals. Pure function — no FS access; callers (scanners, the CLI) * pass the file text. */ export declare function scanFileForEligibility(classify: HandlerBodyClassifier, content: string): FileEligibilityReport;