/** * `src/services/qa/bdd-test-style-contract.ts` * * Verdict types and pure string matchers extracted verbatim from * `bdd-test-style-verifier.ts` (wave 2, file-size cap campaign) so the * verifier stays under the 300 raw-line cap. Mechanical move only — * the verifier re-exports every public type from its original path. */ /** Structured failure reasons the verifier can return. */ export type BddStyleFailureReason = 'missing-given-when-then' | 'description-no-should-when'; /** Successful verdict — includes the count of inspected `it`/`test` calls. */ export interface BddStyleOk { readonly ok: true; readonly scanned: number; } /** Structured failure verdict — the file/line makes the rejection actionable. */ export interface BddStyleFail { readonly ok: false; readonly reason: BddStyleFailureReason; readonly file: string; readonly line: number; /** For `description-no-should-when`: the original description. */ readonly description?: string; /** For `missing-given-when-then`: a stable string the caller can compare. */ readonly expected?: string; } export type BddStyleVerdict = BddStyleOk | BddStyleFail; /** Public input surface — keep small so the contract is hard to misuse. */ export interface VerifyBddStyleInput { readonly projectRoot: string; readonly testFiles: readonly string[]; } /** * Match the three leading comments against the BDD triple. Each * entry must be a `// :` line (with optional trailing * whitespace); the keywords must appear in `given`, `when`, `then` * order, case-insensitive. */ export declare function matchesBddTriple(triple: readonly string[]): boolean; /** True when `text` contains `when` or `should` as a whole word. */ export declare function hasWhenOrShould(text: string): boolean; /** * The leading logical comments of a callback block, in source order. * * The contract's unit is the COMMENT, not the source line * (`contracts/test-style-contract.md` §1.2: the body must start with * "exactly three leading comments"). A `// given:` wrapped onto a second * line is still ONE comment, so it must not consume a second slot and push * `// when:` out of the triple. A comment line that carries no keyword * counts as a continuation of the previous comment only when it is * hanging-indented beneath that comment's text; written at the same column * it is a separate leading comment, and a fourth one violates "exactly * three". * * Scanning stops at the first executable line: only the region before any * executable code is contract-bound, so comments after it are permitted. */ export declare function leadingBddComments(blockBody: string): string[];